/* ============================================================
   دعاياتي — Arabic RTL ads studio
   Se7en design system · light & dark
   ============================================================ */

:root {
  --accent: #6b46ff;
  --accent-2: #d24ce0;
  --accent-soft: rgba(107, 70, 255, 0.11);
  --accent-line: rgba(107, 70, 255, 0.34);

  --green: #1b9d58;
  --amber: #d98708;
  --red: #df464b;
  --blue: #2f6fed;
  --teal: #0d9c9c;
  --pink: #d9378a;

  --bg: #f3f3f8;
  --tint-1: rgba(107, 70, 255, 0.09);
  --tint-2: rgba(210, 76, 224, 0.06);
  --glow: rgba(107, 70, 255, 0.13);
  --sidebar: rgba(255, 255, 255, 0.72);
  --card: #ffffff;
  --card-2: #fafafd;
  --text: #14141b;
  --muted: #63637a;
  --muted-2: #9696a8;
  --line: rgba(18, 18, 42, 0.075);
  --line-strong: rgba(18, 18, 42, 0.14);
  --hover: rgba(18, 18, 42, 0.045);
  --field: #ffffff;
  --track: rgba(18, 18, 42, 0.065);
  --shadow: 0 1px 2px rgba(16, 16, 40, 0.05);
  --shadow-lift: 0 20px 40px -26px rgba(16, 16, 40, 0.45), 0 2px 6px rgba(16, 16, 40, 0.05);
  --shadow-pop: 0 30px 80px -24px rgba(12, 12, 30, 0.4);
  --ring: 0 0 0 3px var(--accent-soft);
  --scroll: rgba(18, 18, 42, 0.2);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur: 0.18s;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #9b86ff;
    --accent-2: #e072ef;
    --accent-soft: rgba(155, 134, 255, 0.16);
    --accent-line: rgba(155, 134, 255, 0.42);

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

    --bg: #0e0e13;
    --tint-1: rgba(155, 134, 255, 0.13);
    --tint-2: rgba(224, 114, 239, 0.08);
    --glow: rgba(155, 134, 255, 0.14);
    --sidebar: rgba(21, 21, 28, 0.76);
    --card: #17171f;
    --card-2: #1c1c25;
    --text: #f4f4f9;
    --muted: #9a9aad;
    --muted-2: #6e6e82;
    --line: rgba(255, 255, 255, 0.075);
    --line-strong: rgba(255, 255, 255, 0.14);
    --hover: rgba(255, 255, 255, 0.06);
    --field: #20202a;
    --track: rgba(255, 255, 255, 0.075);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
    --shadow-lift: 0 24px 48px -28px rgba(0, 0, 0, 0.9), 0 2px 8px rgba(0, 0, 0, 0.35);
    --shadow-pop: 0 30px 80px -20px rgba(0, 0, 0, 0.85);
    --scroll: rgba(255, 255, 255, 0.2);
  }
}

* { 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.5;
  color: var(--text);
  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):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.app {
  position: relative;
  display: flex;
  height: 100vh;
  isolation: isolate;
}

.app::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 520px at 100% 0%, var(--tint-1), transparent 68%),
    radial-gradient(760px 540px at 0% 100%, var(--tint-2), transparent 70%);
}


/* ---------------- sidebar ---------------- */

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

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 36px 8px 16px;
  -webkit-app-region: drag;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow:
    0 8px 20px -10px var(--accent-line),
    inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

.brand-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

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

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

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

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

.nav-item.active {
  background: var(--accent);
  color: #fff;
  box-shadow:
    0 10px 22px -14px var(--accent-line),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.nav-item .icon { color: var(--muted); transition: color var(--dur) var(--ease); }
.nav-item:hover .icon { color: var(--text); }
.nav-item.active .icon { color: rgba(255, 255, 255, 0.94); }

.nav-label {
  flex: 1 1 auto;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-item.active .nav-label { font-weight: 600; }

.nav-count {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--track);
}
.nav-item.active .nav-count {
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
}

.side-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 10px 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--muted-2);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 9px;
  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 {
  border-top: 1px solid var(--line);
  padding: 13px 8px 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.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 / topbar ---------------- */

.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: 14px;
  padding: 34px 28px 18px;
  border-bottom: 1px solid transparent;
  -webkit-app-region: drag;
}

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

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

.topbar-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.6px;
  line-height: 1.25;
}

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

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

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

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

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  cursor: default;
  box-shadow: var(--shadow);
  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(--card-2); border-color: var(--muted-2); }
.btn:active { transform: scale(0.985); }

.btn.primary {
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 88%, #000));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow:
    0 10px 22px -12px var(--accent-line),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.btn.primary:hover { filter: brightness(1.07); border-color: transparent; }

.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 28%, 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; }
.btn:disabled { opacity: 0.42; pointer-events: none; }
.btn.sm { padding: 4px 10px; font-size: 11.5px; border-radius: 8px; }

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

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

.search {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 9px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  min-width: 220px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.search:focus-within { border-color: var(--accent-line); box-shadow: var(--ring); }

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

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

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

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

.segmented button.active {
  background: var(--card);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(10, 10, 30, 0.12);
}

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

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

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 17px;
  box-shadow: var(--shadow);
}

/* pointer-reactive sheen — the parallax hint, kept inside the surface */
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s var(--ease);
  background: radial-gradient(
    300px 220px 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: 7px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 9px;
}
.kpi-label .icon { color: var(--accent); }

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

.kpi-foot { font-size: 10.5px; color: var(--muted); margin-top: 7px; }
.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: 16px;
  margin-bottom: 18px;
  align-items: start;
}

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

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

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

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

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

.tr.head {
  font-size: 10.5px;
  color: var(--muted-2);
  font-weight: 600;
  letter-spacing: 0.2px;
  padding-top: 2px;
  padding-bottom: 6px;
}

.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: 8px; 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 / chips ---------------- */

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

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

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--track);
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
}

.progress {
  height: 6px;
  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.45s var(--ease);
}

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

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

.donut-wrap {
  position: relative;
  width: 190px;
  height: 190px;
  flex: 0 0 190px;
}

.donut-wrap svg { filter: drop-shadow(0 10px 18px rgba(20, 20, 60, 0.08)); }

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

.donut-center .label { font-size: 11px; color: var(--muted); }
.donut-center .value {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

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

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

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 8px;
  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 { font-size: 10.5px; color: var(--muted); width: 44px; text-align: end; }

.bars { display: flex; flex-direction: column; gap: 11px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 76px; gap: 10px; 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);
  font-variant-numeric: tabular-nums;
  text-align: end;
}
.bar-track { height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; transition: width 0.5s var(--ease); }

/* ---------------- flow canvas ---------------- */

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

.palette {
  flex: 0 0 210px;
  width: 210px;
  border-inline-end: 1px solid var(--line);
  padding: 16px 12px;
  overflow-y: auto;
  background: var(--card-2);
}
.palette h4 {
  margin: 0 0 10px;
  font-size: 10.5px;
  color: var(--muted-2);
  font-weight: 600;
  letter-spacing: 0.2px;
}
.palette-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--card);
  margin-bottom: 6px;
  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; }

.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;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  cursor: default;
  transition: box-shadow 0.15s var(--ease), border-color 0.15s var(--ease);
}
.node:hover { box-shadow: var(--shadow-lift); }
.node.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-lift); }
.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: 9px 10px;
  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;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: #fff;
  flex: 0 0 22px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.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: 9px 10px 11px; font-size: 11px; color: var(--muted); line-height: 1.55; }
.node-body b { color: var(--text); font-weight: 600; }

.port {
  position: absolute;
  z-index: 5;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--line-strong);
  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 272px;
  width: 272px;
  border-inline-start: 1px solid var(--line);
  padding: 16px 14px;
  overflow-y: auto;
  background: var(--card-2);
}
.inspector h4 { margin: 0 0 4px; font-size: 13px; font-weight: 650; }
.inspector .sub { font-size: 10.5px; color: var(--muted); margin-bottom: 14px; }
.inspector .field-group { margin-bottom: 11px; }

.console {
  border-top: 1px solid var(--line);
  background: var(--card);
  max-height: 168px;
  overflow-y: auto;
  padding: 9px 14px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  direction: ltr;
  text-align: left;
}
.log-line { display: flex; gap: 8px; padding: 2px 0; color: var(--muted); }
.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(300px, 1fr));
  gap: 14px;
}

.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(-2px);
  box-shadow: var(--shadow-lift);
}

.flow-card .mini-map {
  height: 76px;
  border-radius: 10px;
  background: var(--bg);
  margin-bottom: 11px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
}
.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(276px, 1fr));
  gap: 14px;
}

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

.creative-cta {
  align-self: flex-start;
  padding: 4px 11px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  box-shadow: 0 8px 16px -10px var(--accent-line);
}

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

/* ---------------- list rows ---------------- */

.row-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-radius: 10px;
  cursor: default;
  border-bottom: 1px solid var(--line);
  transition: background var(--dur) var(--ease);
}
.row-item:last-child { border-bottom: 0; }
.row-item:hover { background: var(--hover); }
.row-item .rtitle {
  font-size: 12.5px;
  font-weight: 500;
  flex: 1 1 auto;
  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;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 38px 10px;
}
.empty .icon { opacity: 0.45; }

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

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

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

.modal h3 { margin: 0 0 4px; font-size: 17px; font-weight: 700; letter-spacing: -0.3px; }
.modal .modal-sub { font-size: 11.5px; color: var(--muted); margin-bottom: 16px; }

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

.field {
  width: 100%;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--field);
  color: var(--text);
  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: var(--ring); }
.field::placeholder { color: var(--muted-2); }
textarea.field { resize: vertical; min-height: 80px; line-height: 1.7; }

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

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

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

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: color-mix(in srgb, var(--text) 96%, transparent);
  color: var(--bg);
  padding: 9px 18px;
  border-radius: 11px;
  font-size: 12px;
  z-index: 60;
  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 {
  background: transparent;
  border-radius: 999px;
  border: 3px solid 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 { background: var(--scroll); background-clip: content-box; }

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

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

@media (prefers-reduced-motion: no-preference) {
  .page > *,
  .dash > * { animation: rise 0.34s 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; }
}

/* word-by-word headline reveal (JS-driven, progressive enhancement) */
.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-height: 0;
  min-width: 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; }

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

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

@media (max-width: 900px) {
  .sidebar { flex-basis: 210px; width: 210px; }
  .topbar { padding-inline: 18px; }
  .page { padding-inline: 18px; }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .donut-layout { flex-direction: column; align-items: stretch; }
  .donut-wrap { align-self: center; }
}
