/* ================================================================
   دعاياتي — Arabic RTL ads studio
   Redesign: deeper panels, larger rhythm, same DOM contracts.
   ================================================================ */

:root {
  --accent: #6d4bff;
  --accent-2: #c94cf0;
  --accent-soft: rgba(109, 75, 255, 0.10);
  --accent-line: rgba(109, 75, 255, 0.30);
  --on-accent: #ffffff;

  --green: #17995a;
  --amber: #d0820c;
  --red: #d94a4f;
  --blue: #2f6fed;
  --teal: #0c9797;
  --pink: #d33a86;

  --bg: #f2f1f7;
  --wash-1: rgba(109, 75, 255, 0.10);
  --wash-2: rgba(201, 76, 240, 0.06);
  --sidebar: rgba(255, 255, 255, 0.70);
  --panel: #ffffff;
  --panel-2: #faf9fe;
  --ink: #15141c;
  --muted: #62617a;
  --muted-2: #9695a8;
  --line: rgba(21, 20, 40, 0.08);
  --line-strong: rgba(21, 20, 40, 0.16);
  --hover: rgba(21, 20, 40, 0.045);
  --field: #ffffff;
  --track: rgba(21, 20, 40, 0.065);

  --shadow-1: 0 1px 2px rgba(18, 16, 40, 0.04);
  --shadow-2: 0 26px 50px -34px rgba(18, 16, 40, 0.5), 0 2px 6px rgba(18, 16, 40, 0.04);
  --shadow-pop: 0 40px 90px -30px rgba(14, 12, 32, 0.42);
  --shadow: var(--shadow-1);

  --r-sm: 9px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 26px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur: 0.18s;
  --rail: 268px;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #9a80ff;
    --accent-2: #e072ef;
    --accent-soft: rgba(154, 128, 255, 0.16);
    --accent-line: rgba(154, 128, 255, 0.40);

    --green: #35c377;
    --amber: #f0ad3a;
    --red: #f4696d;
    --blue: #6d9bff;
    --teal: #2bc4c4;
    --pink: #f16fae;

    --bg: #0b0b10;
    --wash-1: rgba(154, 128, 255, 0.14);
    --wash-2: rgba(224, 114, 239, 0.08);
    --sidebar: rgba(18, 18, 25, 0.74);
    --panel: #14141b;
    --panel-2: #1a1a23;
    --ink: #f3f2f9;
    --muted: #9897ab;
    --muted-2: #6c6b80;
    --line: rgba(255, 255, 255, 0.075);
    --line-strong: rgba(255, 255, 255, 0.15);
    --hover: rgba(255, 255, 255, 0.06);
    --field: #1e1e28;
    --track: rgba(255, 255, 255, 0.075);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-2: 0 30px 60px -36px rgba(0, 0, 0, 0.95), 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-pop: 0 40px 90px -26px rgba(0, 0, 0, 0.9);
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Arabic", "Segoe UI",
    "Noto Sans Arabic", system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  user-select: none;
  cursor: default;
}

button { font: inherit; color: inherit; }
input, textarea, select { font: inherit; }

::selection { background: var(--accent-soft); }

:where(button, [role="button"], .nav-item, .brand-row, .row-item, .tr.body,
  .legend-row, .flow-card, .creative-card, .palette-item, .node, .port,
  .icon-btn, .btn, .chip):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.icon { flex: 0 0 auto; display: block; }

/* ---------------- shell ---------------- */

.app {
  position: relative;
  display: flex;
  height: 100vh;
  isolation: isolate;
  background:
    radial-gradient(1100px 620px at 100% -10%, var(--wash-1), transparent 62%),
    radial-gradient(900px 620px at -10% 110%, var(--wash-2), transparent 64%);
}

/* ---------------- rail ---------------- */

.sidebar {
  position: relative;
  z-index: 2;
  flex: 0 0 var(--rail);
  width: var(--rail);
  display: flex;
  flex-direction: column;
  padding: 0 12px 12px;
  overflow: hidden;
  background: var(--sidebar);
  -webkit-backdrop-filter: blur(44px) saturate(180%);
  backdrop-filter: blur(44px) saturate(180%);
  border-inline-end: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 34px 10px 20px;
  -webkit-app-region: drag;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: var(--on-accent);
  background: linear-gradient(150deg, var(--accent), var(--accent-2));
  box-shadow:
    0 12px 24px -14px var(--accent-line),
    inset 0 1px 0 rgba(255, 255, 255, 0.36);
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.35px;
  line-height: 1.15;
}

.brand-sub {
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.side-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 0 10px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  margin-bottom: 3px;
  border-radius: 13px;
  font-size: 13px;
  cursor: default;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.nav-item:hover { background: var(--hover); }

.nav-item.active {
  color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 78%, var(--accent-2)));
  box-shadow:
    0 14px 26px -18px var(--accent-line),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.nav-item > .icon {
  padding: 4px;
  border-radius: 8px;
  box-sizing: content-box;
  color: var(--muted);
  background: var(--track);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}

.nav-item:hover > .icon { color: var(--ink); }

.nav-item.active > .icon {
  color: var(--on-accent);
  background: rgba(255, 255, 255, 0.18);
}

.nav-label {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item.active .nav-label { font-weight: 600; }

.nav-count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  text-align: center;
  color: var(--muted);
  background: var(--track);
  font-variant-numeric: tabular-nums;
}

.nav-item.active .nav-count {
  color: var(--on-accent);
  background: rgba(255, 255, 255, 0.2);
}

.side-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 11px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 11px;
  border-radius: 10px;
  cursor: default;
  transition: background var(--dur) var(--ease);
}

.brand-row:hover { background: var(--hover); }
.brand-row.active { background: var(--accent-soft); }
.brand-row.active .name { font-weight: 600; }

.brand-row .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.brand-row .name {
  flex: 1 1 auto;
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brand-row .count { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.side-foot {
  margin-top: auto;
  padding: 14px 10px 4px;
  border-top: 1px solid var(--line);
}

.side-foot .meter { flex: 1 1 auto; }
.side-foot .t1 { font-size: 11.5px; font-weight: 600; }
.side-foot .t2 { font-size: 10.5px; color: var(--muted); }

/* ---------------- main ---------------- */

.main {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  padding: 30px 32px 18px;
  -webkit-app-region: drag;
}

.topbar > * { -webkit-app-region: no-drag; }

.topbar-titles { flex: 1 1 auto; min-width: 0; }

.topbar-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.9px;
  line-height: 1.2;
}

.topbar-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.view { flex: 1 1 auto; display: flex; min-height: 0; overflow: hidden; }

.page {
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 32px 40px;
}

/* ---------------- controls ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  cursor: default;
  box-shadow: var(--shadow-1);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
    transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.btn:hover { background: var(--panel-2); border-color: var(--muted-2); box-shadow: var(--shadow-2); }
.btn:active { transform: scale(0.985); }

.btn.primary {
  border-color: transparent;
  color: var(--on-accent);
  font-weight: 600;
  background: linear-gradient(160deg, var(--accent), color-mix(in srgb, var(--accent) 84%, #000));
  box-shadow:
    0 14px 26px -16px var(--accent-line),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.btn.primary:hover { filter: brightness(1.07); border-color: transparent; }

.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.btn.danger:hover { background: color-mix(in srgb, var(--red) 8%, transparent); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--hover); border-color: transparent; box-shadow: none; }
.btn:disabled { opacity: 0.42; pointer-events: none; }
.btn.sm { padding: 5px 11px; font-size: 11.5px; border-radius: 9px; }

.icon-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  cursor: default;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.accent { color: var(--accent); }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 230px;
  padding: 7px 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.search:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }

.search input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
}
.search input::placeholder { color: var(--muted-2); }

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
  background: var(--track);
}

.segmented button {
  padding: 6px 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: default;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.segmented button:hover { color: var(--ink); }

.segmented button.active {
  background: var(--panel);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(12, 10, 30, 0.14);
}

/* ---------------- cards ---------------- */

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.card {
  position: relative;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    var(--shadow-1);
}

@media (prefers-color-scheme: dark) {
  .card { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), var(--shadow-1); }
}

/* pointer sheen, driven by motion.js */
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s var(--ease);
  background: radial-gradient(
    320px 240px at var(--mx, 50%) var(--my, 0%),
    color-mix(in srgb, var(--accent) 9%, transparent),
    transparent 72%
  );
}

.card:hover::after { opacity: 1; }

.kpi-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.kpi-label .icon { color: var(--accent); }

.kpi-value {
  font-size: 30px;
  font-weight: 650;
  letter-spacing: -1.1px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-foot { margin-top: 8px; font-size: 10.5px; color: var(--muted); }
.kpi-foot .up { color: var(--green); font-weight: 600; }
.kpi-foot .down { color: var(--red); font-weight: 600; }

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 20px;
  align-items: start;
}

.grid-2.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

.card-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 16px;
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: -0.15px;
}
.card-title .spacer { flex: 1 1 auto; }
.card-title .hint { font-size: 10.5px; font-weight: 400; color: var(--muted); }

/* ---------------- table ---------------- */

.table { display: flex; flex-direction: column; }

.tr {
  display: grid;
  grid-template-columns: 2.2fr 1fr 1fr 1.1fr 0.9fr;
  gap: 12px;
  align-items: center;
  padding: 12px 10px;
  border-radius: 12px;
  cursor: default;
  transition: background var(--dur) var(--ease);
}

.tr.head {
  padding-top: 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.tr.body { border-bottom: 1px solid var(--line); border-radius: 0; }
.tr.body:last-child { border-bottom: 0; }
.tr.body:hover { background: var(--hover); }

.tr.body.selected {
  background: var(--accent-soft);
  box-shadow: inset -3px 0 0 var(--accent);
}

.cell-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.cell-title .dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mono { font-variant-numeric: tabular-nums; }

/* ---------------- badges ---------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  flex: 0 0 5px;
  border-radius: 50%;
  background: currentColor;
}

.badge.live { color: var(--green); background: color-mix(in srgb, var(--green) 13%, transparent); }
.badge.scheduled { color: var(--blue); background: color-mix(in srgb, var(--blue) 13%, transparent); }
.badge.draft { color: var(--muted); background: var(--track); }
.badge.paused { color: var(--amber); background: color-mix(in srgb, var(--amber) 15%, transparent); }
.badge.ended { color: var(--muted-2); background: var(--track); }
.badge.review { color: var(--amber); background: color-mix(in srgb, var(--amber) 15%, transparent); }
.badge.approved { color: var(--green); background: color-mix(in srgb, var(--green) 13%, transparent); }
.badge.rejected { color: var(--red); background: color-mix(in srgb, var(--red) 13%, transparent); }
.badge.failed { color: var(--red); background: color-mix(in srgb, var(--red) 13%, transparent); }
.badge.ok { color: var(--green); background: color-mix(in srgb, var(--green) 13%, transparent); }
.badge.running { color: var(--accent); background: var(--accent-soft); }
.badge.draft::before { opacity: 0.55; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
}

.progress {
  height: 7px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.5s var(--ease);
}

/* ---------------- charts ---------------- */

.donut-layout { display: flex; gap: 22px; align-items: center; }

.donut-wrap { position: relative; width: 190px; height: 190px; flex: 0 0 190px; }
.donut-wrap svg { filter: drop-shadow(0 14px 24px rgba(24, 20, 60, 0.10)); }

.donut-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  padding: 0 46px;
  text-align: center;
  pointer-events: none;
}

.donut-center .label { font-size: 10.5px; color: var(--muted); }
.donut-center .value {
  margin-top: 3px;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.7px;
  font-variant-numeric: tabular-nums;
}

.slice {
  cursor: default;
  transition: stroke-width 0.18s var(--ease), opacity 0.18s var(--ease);
}
.slice:hover, .slice.lit { stroke-width: 34; }

.legend { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }

.legend-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 9px;
  border-radius: 10px;
  cursor: default;
  transition: background 0.14s var(--ease);
}

.legend-row:hover, .legend-row.active { background: var(--accent-soft); }
.legend-row .ldot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.legend-row .lname { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-row .lval {
  margin-inline-start: auto;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.legend-row .lshare { width: 44px; text-align: end; font-size: 10.5px; color: var(--muted); }

.bars { display: flex; flex-direction: column; gap: 13px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 78px; gap: 12px; align-items: center; }
.bar-row .blabel { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bval {
  font-size: 11.5px;
  color: var(--muted);
  text-align: end;
  font-variant-numeric: tabular-nums;
}
.bar-track { height: 9px; border-radius: 999px; background: var(--track); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; transition: width 0.5s var(--ease); }

/* ---------------- flow editor ---------------- */

.flow-shell { flex: 1 1 auto; display: flex; min-height: 0; }

.palette {
  flex: 0 0 224px;
  width: 224px;
  padding: 20px 14px;
  overflow-y: auto;
  border-inline-end: 1px solid var(--line);
  background: var(--panel-2);
}

.palette h4 {
  margin: 0 0 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  margin-bottom: 7px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  font-size: 12px;
  cursor: default;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}

.palette-item:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  transform: translateY(-1px);
}
.palette-item .swatch { width: 8px; height: 8px; border-radius: 3px; flex: 0 0 8px; }

.palette-item.is-blocked {
  opacity: 0.55;
  cursor: not-allowed;
}
.palette-item.is-blocked:hover {
  border-color: var(--line);
  background: var(--panel);
  transform: none;
}
.palette-flag {
  flex: 0 0 auto;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 9.5px;
  letter-spacing: 0.06em;
  color: var(--muted-2);
}

.canvas-wrap {
  flex: 1 1 auto;
  min-width: 0;
  position: relative;
  overflow: auto;
  background: var(--bg);
}

.canvas-world {
  position: relative;
  width: 1700px;
  height: 1200px;
  background-image: radial-gradient(var(--line-strong) 1px, transparent 1px);
  background-size: 22px 22px;
}

.edge-layer { position: absolute; inset: 0; pointer-events: none; }
.edge-layer path { fill: none; stroke: var(--line-strong); stroke-width: 2; }
.edge-layer path.active { stroke: var(--accent); stroke-width: 2.5; }

.node {
  position: absolute;
  width: 218px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
  box-shadow: var(--shadow-1);
  cursor: default;
  transition: box-shadow 0.15s var(--ease), border-color 0.15s var(--ease);
}
.node:hover { box-shadow: var(--shadow-2); }
.node.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-2); }
.node.running { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.node.done { border-color: color-mix(in srgb, var(--green) 50%, transparent); }
.node.failed { border-color: color-mix(in srgb, var(--red) 55%, transparent); }

.node-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  border-radius: var(--r-md) var(--r-md) 0 0;
  cursor: grab;
}
.node-head:active { cursor: grabbing; }

.node-head .nicon {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.node-name {
  font-size: 12px;
  font-weight: 600;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.node-type { font-size: 9.5px; color: var(--muted); }
.node-body { padding: 10px 11px 12px; font-size: 11px; line-height: 1.55; color: var(--muted); }
.node-body b { color: var(--ink); font-weight: 600; }

.port {
  position: absolute;
  z-index: 5;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  background: var(--panel);
  cursor: crosshair;
  transition: border-color 0.14s var(--ease), background 0.14s var(--ease);
}
.port.in { top: -7px; right: calc(50% - 6px); }
.port.out { bottom: -7px; right: calc(50% - 6px); }
.port.out.alt { right: calc(50% + 34px); }
.port:hover, .port.hot { border-color: var(--accent); background: var(--accent); }

.inspector {
  flex: 0 0 288px;
  width: 288px;
  padding: 20px 16px;
  overflow-y: auto;
  border-inline-start: 1px solid var(--line);
  background: var(--panel-2);
}
.inspector h4 { margin: 0 0 4px; font-size: 13.5px; font-weight: 650; }
.inspector .sub { margin-bottom: 16px; font-size: 10.5px; color: var(--muted); }
.inspector .field-group { margin-bottom: 12px; }

.console {
  max-height: 172px;
  padding: 10px 16px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
  background: var(--panel);
  font-family: -apple-system, BlinkMacSystemFont, "SF Arabic", "Segoe UI", "Noto Sans Arabic", system-ui, sans-serif;
  font-size: 11.5px;
  line-height: 1.7;
  direction: rtl;
  text-align: right;
}

.log-line {
  display: flex;
  gap: 8px;
  padding: 3px 0;
  color: var(--muted);
}

/* each entry follows its own first strong character, so Arabic and
   latin detail text both read correctly inside one console */
.log-line > span { unicode-bidi: plaintext; }
.log-line > span:last-child { overflow-wrap: anywhere; }
.log-line .node-id {
  flex: 0 0 auto;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10.5px;
}
.log-line .ok { color: var(--green); }
.log-line .err { color: var(--red); }
.log-line .node-id { color: var(--accent); }

.flow-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}

.flow-card,
.creative-card {
  cursor: default;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}

.flow-card:hover,
.creative-card:hover {
  border-color: var(--accent-line);
  transform: translateY(-3px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    var(--shadow-2);
}

.flow-card .mini-map {
  position: relative;
  height: 84px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  overflow: hidden;
}
.flow-card .mini-dot { position: absolute; width: 16px; height: 9px; border-radius: 3px; }

/* ---------------- creatives ---------------- */

.creative-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(286px, 1fr));
  gap: 16px;
}

.creative-card { display: flex; flex-direction: column; gap: 10px; }
.creative-head { display: flex; align-items: center; gap: 8px; }
.creative-headline { font-size: 15.5px; font-weight: 700; line-height: 1.45; letter-spacing: -0.25px; }
.creative-body { font-size: 12px; line-height: 1.72; color: var(--muted); }

.creative-cta {
  align-self: flex-start;
  padding: 5px 12px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 600;
  box-shadow: 0 10px 20px -12px var(--accent-line);
}

.creative-foot { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 2px; }

/* ---------------- rows / empty ---------------- */

.row-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 9px;
  border-bottom: 1px solid var(--line);
  border-radius: 10px;
  cursor: default;
  transition: background var(--dur) var(--ease);
}
.row-item:last-child { border-bottom: 0; }
.row-item:hover { background: var(--hover); }

.row-item .rtitle {
  flex: 1 1 auto;
  font-size: 12.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-item .rmeta { font-size: 10.5px; color: var(--muted); }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 44px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.empty .icon { opacity: 0.42; }

/* ---------------- demo / onboarding ---------------- */

.demo-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 18px;
  padding: 11px 15px;
  border: 1px solid color-mix(in srgb, var(--amber) 36%, transparent);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--amber) 10%, transparent);
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--ink);
}
.demo-banner .spacer { flex: 1 1 auto; }

.start-card { margin-bottom: 18px; padding: 28px; }
.start-title { font-size: 19px; font-weight: 700; letter-spacing: -0.4px; }
.start-sub {
  max-width: 56ch;
  margin: 8px 0 18px;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--muted);
}
.start-actions { display: flex; gap: 9px; flex-wrap: wrap; }

/* ---------------- modal ---------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, #0a0a18 34%, transparent);
  -webkit-backdrop-filter: blur(7px) saturate(120%);
  backdrop-filter: blur(7px) saturate(120%);
  animation: fade 0.16s var(--ease);
}

.modal {
  width: 500px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 64px);
  padding: 24px;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xl);
  background: var(--panel);
  box-shadow: var(--shadow-pop);
  animation: pop 0.2s var(--ease);
}

.modal h3 { margin: 0 0 5px; font-size: 18px; font-weight: 700; letter-spacing: -0.4px; }
.modal .modal-sub { margin-bottom: 18px; font-size: 11.5px; line-height: 1.7; color: var(--muted); }

.field-group { margin-bottom: 13px; }
.field-label { display: block; margin-bottom: 6px; font-size: 11px; font-weight: 500; color: var(--muted); }

.field {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--field);
  color: var(--ink);
  font-size: 12.5px;
  outline: 0;
  user-select: text;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field::placeholder { color: var(--muted-2); }
textarea.field { min-height: 84px; line-height: 1.7; resize: vertical; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }

.modal-actions { display: flex; align-items: center; gap: 9px; margin-top: 20px; }
.modal-actions .spacer { flex: 1 1 auto; }

/* ---------------- toast ---------------- */

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  z-index: 60;
  padding: 10px 20px;
  transform: translateX(-50%);
  border-radius: 12px;
  background: color-mix(in srgb, var(--ink) 96%, transparent);
  color: var(--bg);
  font-size: 12px;
  box-shadow: var(--shadow-pop);
  animation: pop 0.2s var(--ease);
}

/* ---------------- scrollbars ---------------- */

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: transparent;
  background-clip: content-box;
}
.page:hover::-webkit-scrollbar-thumb,
.side-scroll:hover::-webkit-scrollbar-thumb,
.canvas-wrap:hover::-webkit-scrollbar-thumb,
.inspector:hover::-webkit-scrollbar-thumb,
.palette:hover::-webkit-scrollbar-thumb,
.modal:hover::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--ink) 22%, transparent);
  background-clip: content-box;
}

/* ---------------- animation ---------------- */

@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: none; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .page > *,
  .dash > * { animation: rise 0.36s var(--ease) both; }
  .page > *:nth-child(2),
  .dash > *:nth-child(2) { animation-delay: 0.04s; }
  .page > *:nth-child(3),
  .dash > *:nth-child(3) { animation-delay: 0.08s; }
  .page > *:nth-child(4),
  .dash > *:nth-child(4) { animation-delay: 0.12s; }
  .page > *:nth-child(n+5),
  .dash > *:nth-child(n+5) { animation-delay: 0.16s; }
}

.reveal-word { display: inline-block; will-change: opacity, filter, transform; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .card::after { display: none; }
}

/* ---------------- flow editor shell ---------------- */

.editor {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.flow-shell { flex: 1 1 auto; min-height: 0; }

.node .port.out.alt { bottom: -7px; }

/* canvas uses LTR coordinates; node content stays RTL */
.canvas-wrap { direction: ltr; }
.canvas-world { direction: ltr; }
.node { direction: rtl; text-align: right; }
.inspector .field, .inspector textarea { direction: rtl; text-align: right; }

/* ---------------- account bar ---------------- */

#accountBar { padding: 8px 8px 2px; }

/* ---------------- responsive ---------------- */

@media (max-width: 1180px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-2.even { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 780px) {
  .app { flex-direction: column; height: 100dvh; }

  .sidebar {
    flex: 0 0 auto;
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    overflow-x: auto;
    overflow-y: hidden;
    border-inline-end: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand { padding: 2px 6px; flex: 0 0 auto; }
  .brand-title, .brand-sub { display: none; }
  .brand-mark { width: 32px; height: 32px; flex-basis: 32px; border-radius: 10px; }

  .side-scroll {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    overflow: visible;
    flex: 1 1 auto;
  }
  .side-scroll .side-section, .side-foot { display: none; }

  .nav-item, .brand-row { flex: 0 0 auto; margin: 0; padding: 7px 10px; }
  .nav-count { display: none; }

  #accountBar { flex: 0 0 auto; padding: 0; }
  .s7-account-bar span:first-child { display: none; }

  .main { min-height: 0; }

  .topbar {
    padding: 12px 16px 14px;
    flex-wrap: wrap;
    align-items: center;
  }
  .topbar-title { font-size: 20px; letter-spacing: -0.5px; }
  .topbar-sub { display: none; }
  .topbar-actions { flex-wrap: wrap; }

  .page { padding: 4px 16px 28px; }
  .search { min-width: 0; flex: 1 1 160px; }

  .cards { grid-template-columns: minmax(0, 1fr); }
  .donut-layout { flex-direction: column; align-items: stretch; }
  .donut-wrap { align-self: center; }

  .flow-shell { flex-direction: column; }
  .palette {
    flex: 0 0 auto;
    width: auto;
    max-height: 136px;
    border-inline-end: 0;
    border-bottom: 1px solid var(--line);
  }
  .inspector {
    flex: 0 0 auto;
    width: auto;
    max-height: 240px;
    border-inline-start: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 430px) {
  .cards { grid-template-columns: minmax(0, 1fr); }
  .modal { padding: 18px; border-radius: 20px; }
}

/* ---------------- wordmark lockup v2 (sources: resources/wordmarks-v2) ---------------- */

.brand { flex-direction: column; align-items: flex-start; gap: 9px; }

.brand-mark--word {
  width: auto;
  height: auto;
  flex: 0 0 auto;
  border-radius: 0;
  display: block;
  place-items: initial;
  color: inherit;
  background: none;
  box-shadow: none;
}

.brand-mark--word .brand-wordmark {
  display: block;
  width: 118px;
  height: auto;
}

@media (max-width: 780px) {
  .brand-mark.brand-mark--word { width: auto; flex-basis: auto; border-radius: 0; }
  .brand-mark--word .brand-wordmark { width: 92px; }
  .brand { padding: 8px 6px; gap: 0; }
}
