/* ============================================================
   Rabtek Guide Studio — design system
   Direction: editorial studio — warm paper chrome, ink accents,
   client brand colors carried by the slides themselves.
   ============================================================ */

@font-face {
  font-family: "Plex Arabic";
  src: url("../assets/fonts/IBMPlexSansArabic-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Plex Arabic";
  src: url("../assets/fonts/IBMPlexSansArabic-Medium.ttf") format("truetype");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Plex Arabic";
  src: url("../assets/fonts/IBMPlexSansArabic-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Plex Arabic";
  src: url("../assets/fonts/IBMPlexSansArabic-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Alexandria";
  src: url("../assets/fonts/Alexandria-Variable.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --paper: #f2efe9;
  --paper-2: #faf8f3;
  --card: #ffffff;
  --ink: #1a1b20;
  --ink-2: #57534a;
  --ink-3: #8d877a;
  --line: #e6e2d8;
  --line-2: #d6d0c2;

  --brand: #23405a;
  --brand-d: #182f44;
  --brand-ink: #1d364c;
  --brand-on: #ffffff;
  --brand-s: #edf2f6;
  --brand-s2: #d9e3ea;
  --accent: #c08a3e;
  --accent-d: #9a6f32;
  --accent-s: #f7efe3;
  --accent-on: #ffffff;

  --danger: #b0442f;
  --danger-s: #f7e9e4;

  --radius: 12px;
  --font-ui: "Plex Arabic", "Segoe UI", Tahoma, sans-serif;
  --font-display: "Alexandria", "Plex Arabic", "Segoe UI", Tahoma, sans-serif;

  --shadow-1: 0 1px 2px rgba(26, 27, 32, 0.05), 0 10px 28px -18px rgba(26, 27, 32, 0.28);
  --shadow-2: 0 2px 8px rgba(26, 27, 32, 0.06), 0 32px 70px -32px rgba(26, 27, 32, 0.4);

  --stage-scale: 1;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 13.5px;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font-family: inherit; }
input, textarea, select { font-family: inherit; color: inherit; }
::selection { background: var(--brand-s2); }

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; border: 2px solid var(--paper-2); }
::-webkit-scrollbar-track { background: transparent; }

/* ============================== app frame ============================== */
#app { height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: 62px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 30;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(140deg, var(--brand), var(--brand-d) 65%, var(--accent));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 14px -8px color-mix(in srgb, var(--brand) 70%, transparent);
}
.brand-mark .ic { width: 19px; height: 19px; }
.brand-name { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name strong { font-family: var(--font-display); font-size: 14px; font-weight: 700; letter-spacing: -0.2px; }
.brand-name span { font-size: 10.5px; color: var(--ink-3); }

.topbar-title { flex: 1; display: flex; justify-content: center; min-width: 0; }
.topbar-title input {
  width: min(440px, 100%);
  height: 34px;
  text-align: center;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  outline: none;
  transition: background 0.15s, border-color 0.15s;
}
.topbar-title input:hover { background: var(--paper); }
.topbar-title input:focus { background: #fff; border-color: var(--line-2); box-shadow: 0 0 0 3px var(--brand-s); }

.topbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.topbar-sep { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }

/* ============================== controls ============================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border-radius: 9px;
  border: 1px solid var(--line-2);
  background: #fff;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, transform 0.06s, box-shadow 0.15s;
}
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn .ic { width: 15px; height: 15px; }
.btn-gradient {
  border: 0;
  color: #fff;
  background: linear-gradient(120deg, var(--brand) 20%, var(--brand-d) 80%);
  box-shadow: 0 8px 18px -10px color-mix(in srgb, var(--brand) 80%, transparent);
  padding: 0 16px;
}
.btn-gradient:hover { filter: brightness(1.07); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: #fff; border-color: var(--line); }
.btn-quiet.is-danger { color: var(--danger); }
.btn-quiet.is-danger:hover { background: var(--danger-s); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 11.5px; border-radius: 8px; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

.icon-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.icon-btn:hover { background: #fff; border-color: var(--line); color: var(--ink); }
.icon-btn[disabled] { opacity: 0.35; pointer-events: none; }
.icon-btn .ic { width: 17px; height: 17px; }

.menu-wrap { position: relative; }
.menu {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  min-width: 230px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-2);
  padding: 6px;
  z-index: 60;
  animation: popIn 0.14s ease;
}
.menu button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  text-align: start;
}
.menu button:hover { background: var(--paper); }
.menu button .ic { width: 15px; height: 15px; color: var(--ink-3); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }

/* ============================== workspace ============================== */
.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 246px minmax(0, 1fr) 324px;
}

/* ---- slides rail (RTL: right column) ---- */
.rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--paper-2);
  border-inline-start: 1px solid var(--line);
}
.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
}
.rail-head h2 { margin: 0; font-size: 12px; font-weight: 700; color: var(--ink-2); letter-spacing: 0.02em; }
.rail-count { font-size: 11px; color: var(--ink-3); background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }

.rail-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fadeUp 0.35s ease both;
}
.slide-item {
  position: relative;
  padding: 7px;
  border-radius: 11px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.slide-item:hover { background: rgba(255, 255, 255, 0.75); }
.slide-item.is-active { background: #fff; border-color: var(--line); box-shadow: 0 8px 18px -14px rgba(26, 27, 32, 0.35); }
.slide-item.is-active .thumb { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-s2); }

.thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 7px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #fff;
}
.thumb-clip { position: absolute; inset: 0; overflow: hidden; }
.thumb-clip > .thumb-slide { position: absolute; top: 0; left: 0; transform-origin: top left; pointer-events: none; }
.thumb-no {
  position: absolute;
  top: 6px;
  inset-inline-start: 6px;
  z-index: 2;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  border-radius: 6px;
  background: rgba(20, 21, 26, 0.55);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.slide-item-actions {
  position: absolute;
  bottom: 11px;
  inset-inline-start: 11px;
  z-index: 3;
  display: flex;
  gap: 3px;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.15s, transform 0.15s;
}
.slide-item:hover .slide-item-actions,
.slide-item.is-active .slide-item-actions { opacity: 1; transform: none; }
.slide-item-actions button {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink-2);
  cursor: pointer;
}
.slide-item-actions button:hover { color: var(--ink); border-color: var(--ink-3); }
.slide-item-actions button.is-danger:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-s); }
.slide-item-actions .ic { width: 12px; height: 12px; }

.rail-foot { flex: none; border-top: 1px solid var(--line); padding: 10px 12px 12px; }
.add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.add-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 9px;
  border: 1px dashed var(--line-2);
  border-radius: 9px;
  background: transparent;
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.add-btn:hover { background: #fff; border-color: var(--ink-3); color: var(--ink); }
.add-btn .ic { width: 14px; height: 14px; color: var(--ink-3); }
.save-state {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  font-size: 10.8px;
  color: var(--ink-3);
}
.save-state .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); flex: none; }
.save-state.is-saving .dot { background: var(--accent); }
.save-state.is-saved .dot { background: #4c8a5f; }
.save-state.is-error .dot { background: var(--danger); }

/* ---- canvas ---- */
.canvas {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--paper);
}
.canvas-bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 22px 4px;
  animation: fadeUp 0.3s ease both;
}
.seg {
  display: flex;
  gap: 3px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  box-shadow: var(--shadow-1);
}
.tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 31px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
.tool .ic { width: 15px; height: 15px; }
.tool:hover { background: var(--paper); color: var(--ink); }
.tool.is-active { background: var(--ink); color: #fff; }
.canvas-actions { display: flex; align-items: center; gap: 4px; }

.stage-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 26px 8px;
  background-image: radial-gradient(circle, rgba(26, 27, 32, 0.12) 1px, transparent 1.4px);
  background-size: 22px 22px;
  background-position: center;
}
.stage-scaler { position: relative; }
.stage {
  position: absolute;
  top: 0;
  left: 0;
  width: 1280px;
  height: 720px;
  transform: scale(var(--stage-scale, 1));
  transform-origin: top left;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 44px 90px -45px rgba(20, 21, 26, 0.55), 0 4px 16px rgba(20, 21, 26, 0.08);
  animation: stageIn 0.4s cubic-bezier(0.2, 0.8, 0.25, 1);
}
.stage-wrap.is-dragover { outline: 2px dashed var(--brand); outline-offset: -14px; background-color: var(--brand-s); }
.stage > .slide { border-radius: 0; }

.canvas-foot {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 4px 22px 12px;
  font-size: 11px;
  color: var(--ink-3);
  min-height: 26px;
}
.canvas-foot kbd {
  font-family: inherit;
  font-size: 10px;
  background: #fff;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0.5px 5px;
}

/* ---- inspector ---- */
.inspector {
  min-height: 0;
  overflow-y: auto;
  background: var(--paper-2);
  border-inline-end: 1px solid var(--line);
  padding: 16px 16px 30px;
  animation: fadeUp 0.4s 0.05s ease both;
}
.ins-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.ins-head h3 { margin: 0; font-size: 13px; font-weight: 700; }
.ins-head .sub { font-size: 11px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--brand-ink);
  background: var(--brand-s);
  border-radius: 999px;
  padding: 2px 9px;
}
.ins-section { padding: 14px 0 4px; border-bottom: 1px solid var(--line); }
.ins-section:last-child { border-bottom: 0; }
.ins-section h4 {
  margin: 0 0 10px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink-3);
  letter-spacing: 0.03em;
}
.field { display: block; margin-bottom: 10px; }
.field-label { display: block; font-size: 11.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field input[type="text"],
.field input[type="number"],
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: #fff;
  padding: 8px 10px;
  font-size: 12.5px;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field textarea { resize: vertical; min-height: 64px; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-s);
}
.field .hint { margin: 5px 0 0; font-size: 10.5px; color: var(--ink-3); line-height: 1.5; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.markers-list { display: flex; flex-direction: column; gap: 7px; }
.marker-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 26px;
  gap: 8px;
  align-items: start;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.marker-row.is-selected { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-s); }
.marker-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-on);
  font-size: 11.5px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
}
.marker-row textarea {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  padding: 3px 4px;
  font-size: 12px;
  line-height: 1.55;
  min-height: 44px;
  resize: vertical;
  outline: none;
  width: 100%;
}
.marker-row textarea:hover { border-color: var(--line); background: var(--paper-2); }
.marker-row textarea:focus { border-color: var(--brand); background: #fff; }
.marker-row .icon-btn { width: 26px; height: 26px; }
.marker-row .icon-btn .ic { width: 14px; height: 14px; }

.empty-note {
  padding: 14px;
  border: 1px dashed var(--line-2);
  border-radius: 10px;
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.7;
  text-align: center;
  background: rgba(255, 255, 255, 0.5);
}

.img-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.color-mini { display: flex; align-items: center; gap: 8px; }
.color-mini input[type="color"] {
  width: 34px; height: 34px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 3px;
  background: #fff;
  cursor: pointer;
  flex: none;
}
.color-mini input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 5px; }
.color-mini input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-mini .lbl { font-size: 11.5px; color: var(--ink-2); flex: 1; }
.color-mini .btn { flex: none; }

.object-meta { font-size: 11px; color: var(--ink-3); margin: -4px 0 10px; }

/* ============================== toast / modal ============================== */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 11px;
  box-shadow: var(--shadow-2);
  z-index: 200;
  animation: toastIn 0.2s ease;
  max-width: 80vw;
}
.toast--warn { background: #7a5a18; }
.toast--error { background: var(--danger); }

.modal-root:empty { display: none; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(22, 23, 28, 0.42);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.16s ease;
}
.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  background: var(--paper-2);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 50px 120px -30px rgba(10, 11, 15, 0.6);
  animation: modalIn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.1);
  overflow: hidden;
}
.modal-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 12px;
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-body { padding: 4px 24px 18px; overflow-y: auto; }
.modal-foot {
  flex: none;
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  padding: 14px 24px 18px;
  border-top: 1px solid var(--line);
  background: #fff;
}

/* brand modal */
.brand-modal { display: flex; flex-direction: column; gap: 6px; }
.brand-section { padding: 12px 0; border-bottom: 1px solid var(--line); }
.brand-section:last-child { border-bottom: 0; }
.brand-section h4 { margin: 0 0 10px; font-size: 12px; font-weight: 700; color: var(--ink); }
.brand-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.brand-section-head h4 { margin: 0; }
.brand-grid { display: grid; grid-template-columns: 108px 1fr; gap: 14px; align-items: start; }
.logo-drop {
  position: relative;
  width: 108px;
  height: 74px;
  border: 1.5px dashed var(--line-2);
  border-radius: 11px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s, background 0.15s;
}
.logo-drop:hover { border-color: var(--brand); background: var(--brand-s); }
.logo-drop img { max-width: 88%; max-height: 80%; object-fit: contain; }
.logo-drop-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--ink-3); font-size: 10.5px; font-weight: 600; }
.logo-drop-empty .ic { width: 20px; height: 20px; }
.logo-remove {
  position: absolute;
  top: 4px;
  inset-inline-end: 4px;
  width: 20px; height: 20px;
  border: 0;
  border-radius: 5px;
  background: rgba(20, 21, 26, 0.55);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.logo-remove .ic { width: 12px; height: 12px; }

.auto-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ink-2); font-weight: 500; cursor: pointer; }
.auto-toggle input { accent-color: var(--brand); }

.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  margin-bottom: 8px;
}
.color-input {
  width: 40px; height: 40px;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  padding: 3px;
  background: #fff;
  cursor: pointer;
  flex: none;
}
.color-input::-webkit-color-swatch { border: 0; border-radius: 6px; }
.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-meta { display: flex; flex-direction: column; gap: 1px; }
.color-name { font-size: 12px; font-weight: 600; color: var(--ink); }
.color-hex { font-size: 10.5px; color: var(--ink-3); letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.extract-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }

.preset-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; max-height: 190px; overflow-y: auto; }
.preset {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.preset-swatches { display: flex; flex: none; }
.preset-swatches .swatch { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; margin-inline-start: -4px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); }
.preset-swatches .swatch:first-child { margin-inline-start: 0; }
.preset-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.4; }
.preset-meta strong { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preset-meta span { font-size: 10.5px; color: var(--ink-3); }
.preset .icon-btn { width: 26px; height: 26px; }
.preset .icon-btn .ic { width: 13px; height: 13px; }
.preset-save { display: flex; gap: 6px; }
.preset-save input {
  flex: 1;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  outline: none;
  background: #fff;
}
.preset-save input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-s); }
.muted { color: var(--ink-3); font-size: 11.5px; margin: 4px 0; }

/* generic info/instruction lists (export modal) */
.steps { margin: 10px 0 0; padding: 0 18px 0 0; font-size: 12.5px; line-height: 1.9; color: var(--ink-2); }
.steps li::marker { color: var(--accent-d); font-weight: 700; }
.callout {
  background: var(--accent-s);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink-2);
  margin-top: 12px;
}
.format-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 2px; }
.format-option {
  position: relative;
  border: 1.5px solid var(--line-2);
  border-radius: 11px;
  padding: 12px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.format-option input { position: absolute; opacity: 0; pointer-events: none; }
.format-option .fmt-name { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink); }
.format-option .fmt-desc { display: block; font-size: 10.5px; color: var(--ink-3); margin-top: 3px; }
.format-option.is-checked { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-s); }
.format-option.is-checked .fmt-name { color: var(--brand-ink); }

/* ============================================================
   SLIDES (1280 × 720 designed stage)
   ============================================================ */
.slide {
  width: 1280px;
  height: 720px;
  position: relative;
  overflow: hidden;
  background: #fff;
  color: var(--ink);
  font-family: var(--font-ui);
  display: flex;
  flex-direction: column;
}
.slide, .slide * { box-sizing: border-box; }

.s-topline {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  z-index: 5;
}
.s-orn {
  position: absolute;
  z-index: 0;
  pointer-events: none;
  inset: 0;
  background:
    radial-gradient(640px 380px at 103% 108%, var(--brand-s) 0%, rgba(255, 255, 255, 0) 62%),
    radial-gradient(420px 260px at -6% -4%, var(--accent-s) 0%, rgba(255, 255, 255, 0) 60%);
  opacity: 0.75;
}

/* header */
.s-head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 30px;
  padding: 36px 52px 0;
  flex: none;
}
.s-titles { min-width: 0; max-width: 640px; }
.s-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 29px;
  line-height: 1.42;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--ink);
}
.s-sub { margin: 7px 0 0; font-size: 14.5px; line-height: 1.6; color: var(--ink-2); }

.s-logos { display: flex; align-items: center; gap: 12px; flex: none; padding-top: 4px; }
.s-identity { display: flex; align-items: center; gap: 8px; }
.s-identity img { height: 30px; max-width: 116px; object-fit: contain; display: block; }
.s-identity .name { font-size: 12.5px; font-weight: 600; color: var(--ink-2); white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.s-identity--client {
  background: var(--brand-s);
  border: 1px solid color-mix(in srgb, var(--brand) 16%, transparent);
  padding: 6px 11px;
  border-radius: 10px;
}
.s-identity--client .name { color: var(--brand-ink); font-weight: 700; }
.s-identity--provider .name { font-weight: 500; color: var(--ink-3); font-size: 12px; }
.s-logo-sep { width: 1px; height: 26px; background: var(--line-2); }
.logo-fallback {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--brand);
  color: var(--brand-on);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  text-transform: uppercase;
}
.s-identity--provider .logo-fallback { background: var(--ink); color: #fff; }

/* body */
.s-body {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 24px;
  padding: 20px 52px 10px;
}

/* legend */
.s-legend {
  flex: none;
  width: 296px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-top: 2px;
}
.s-legend.has-cols { width: 424px; }
.legend-kicker {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent-d);
  letter-spacing: 0.06em;
  padding-bottom: 7px;
  margin-bottom: 10px;
  border-bottom: 2px solid var(--accent);
  align-self: flex-start;
  flex: none;
}
.legend-list { display: flex; flex-direction: column; gap: 9px; overflow: hidden; min-height: 0; }
.s-legend.has-cols .legend-list { display: block; column-count: 2; column-gap: 20px; }
.legend-item { display: grid; grid-template-columns: 23px minmax(0, 1fr); gap: 8px; align-items: start; padding: 1px 0; break-inside: avoid; }
.legend-num {
  width: 23px; height: 23px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-on);
  font-size: 11.5px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
  flex: none;
}
.legend-txt { font-size: 12.8px; line-height: 1.62; color: var(--ink); min-height: 1em; white-space: pre-wrap; overflow-wrap: anywhere; outline: none; }
.legend-txt:focus { background: var(--brand-s); border-radius: 4px; box-shadow: 0 0 0 2px var(--brand-s2); }
.stage.editing .legend-txt:empty::before { content: "اكتب شرح الرقم…"; color: var(--ink-3); }
.s-legend.legend-dense .legend-list { gap: 6px; }
.s-legend.legend-dense .legend-txt { font-size: 11.8px; line-height: 1.55; }

/* screenshot frame */
.s-shot-frame {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 14px 34px -24px rgba(26, 27, 32, 0.35);
  overflow: hidden;
}
.shot {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  overflow: visible;
}
.shot-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 6px;
  user-select: none;
  -webkit-user-drag: none;
}
.shot-empty {
  position: absolute;
  inset: 10px;
  border: 1.5px dashed var(--line-2);
  border-radius: 9px;
  background: var(--paper-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--ink-3);
  text-align: center;
  padding: 20px;
}
.shot-empty .ic { width: 30px; height: 30px; opacity: 0.6; }
.shot-empty strong { font-size: 15px; color: var(--ink-2); font-weight: 700; }
.shot-empty span { font-size: 12px; line-height: 1.6; max-width: 380px; }
.shot-empty .btn { margin-top: 6px; pointer-events: auto; }

/* notes + footer */
.s-note {
  position: relative;
  z-index: 1;
  margin: 0 52px 8px;
  background: var(--brand-s);
  border-inline-start: 3px solid var(--brand);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  line-height: 1.65;
  color: var(--brand-ink);
  flex: none;
}
.s-foot {
  position: relative;
  z-index: 1;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: auto;
  padding: 11px 52px 15px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-3);
}
.s-foot-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s-foot-meta { color: var(--ink-3); display: flex; align-items: center; gap: 7px; }
.s-foot-meta .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--line-2); }
.page-badge {
  flex: none;
  background: var(--brand-s);
  color: var(--brand-ink);
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 10.5px;
  letter-spacing: 0.03em;
}

/* ---- cover / closing ---- */
.slide--cover, .slide--closing {
  background: #14151a;
  color: #fff;
  justify-content: flex-start;
}
.cover-art {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(920px 640px at 92% -12%, color-mix(in srgb, var(--brand) 78%, transparent) 0%, rgba(20, 21, 26, 0) 58%),
    radial-gradient(760px 540px at 4% 112%, color-mix(in srgb, var(--accent) 46%, transparent) 0%, rgba(20, 21, 26, 0) 62%),
    linear-gradient(155deg, #1d1f26 0%, #131419 62%, #101116 100%);
}
.cover-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(80% 80% at 50% 40%, #000 30%, transparent 100%);
}
.cover-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 46px 56px 36px;
}
.cover-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex: none; }
.logo-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 9px 14px;
  backdrop-filter: blur(8px);
  max-width: 340px;
}
.logo-card img { height: 32px; max-width: 150px; object-fit: contain; display: block; }
.logo-card .nm { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo-card .logo-fallback { background: rgba(255, 255, 255, 0.92); color: var(--brand-ink); }
.cover-main { margin-top: auto; margin-bottom: auto; max-width: 900px; padding-top: 20px; }
.cover-kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: color-mix(in srgb, var(--accent) 72%, #fff);
}
.cover-kicker::before { content: ""; width: 44px; height: 3px; border-radius: 2px; background: var(--accent); }
.cover-title {
  margin: 20px 0 0;
  font-family: var(--font-display);
  font-size: 58px;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -0.8px;
  color: #fff;
}
.cover-sub { margin: 16px 0 0; font-size: 17px; line-height: 1.85; color: rgba(255, 255, 255, 0.62); max-width: 720px; }
.slide--closing .cover-foot { width: 100%; }
.cover-foot {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.13);
  color: rgba(255, 255, 255, 0.5);
  font-size: 11.5px;
}
.cover-foot .who { display: flex; align-items: center; gap: 8px; }
.cover-foot .who b { color: rgba(255, 255, 255, 0.78); font-weight: 600; }

.closing-inner { align-items: center; text-align: center; justify-content: space-between; }
.closing-main { margin: auto 0; max-width: 860px; text-align: center; }
.closing-title { font-size: 64px; margin-top: 0; }
.closing-logos { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 26px; }

/* ---- text slide ---- */
.slide--text .s-body { display: block; padding-top: 8px; }
.t-rich {
  font-size: 16.5px;
  line-height: 1.95;
  color: var(--ink-2);
  max-width: 980px;
}
.t-rich p { margin: 0 0 12px; }
.t-rich ul { margin: 0 0 12px; padding: 0; list-style: none; }
.t-rich li { position: relative; padding-inline-start: 20px; margin-bottom: 9px; }
.t-rich li::before {
  content: "";
  position: absolute;
  inset-inline-start: 3px;
  top: 0.72em;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--accent);
}
.t-rich strong { color: var(--ink); font-weight: 700; }

/* ============================================================
   editor overlay objects
   ============================================================ */
.overlay { position: absolute; inset: 0; overflow: visible; }
.stage.editing .overlay { touch-action: none; }

.mk {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: var(--mk-color, var(--brand));
  color: var(--brand-on);
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 9px rgba(16, 17, 22, 0.35);
  z-index: 4;
  user-select: none;
}
.stage.editing .mk { cursor: grab; }
.stage.editing .mk:hover { transform: translate(-50%, -50%) scale(1.1); }
.mk.is-selected { outline: 3px solid color-mix(in srgb, var(--accent) 85%, transparent); outline-offset: 1.5px; }
.mk.is-pop { animation: mkPop 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.4); }

.sh-highlight {
  position: absolute;
  border: 2px solid var(--sh-color, var(--accent));
  background: color-mix(in srgb, var(--sh-color, var(--accent)) 20%, transparent);
  border-radius: 5px;
  z-index: 2;
}
.stage.editing .sh-highlight { cursor: move; }
.sh-handle {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--sh-color, var(--accent));
  z-index: 6;
  display: none;
}
.stage.editing .is-selected > .sh-handle { display: block; }
.stage.editing .sh-handle { cursor: nwse-resize; }

.sh-arrow { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 3; overflow: visible; pointer-events: none; }
.sh-arrow .arrow-hit { stroke: transparent; stroke-width: 18; fill: none; pointer-events: none; }
.sh-arrow .arrow-line { stroke: var(--sh-color, var(--brand)); stroke-width: 3.2; fill: none; stroke-linecap: round; }
.stage.editing .sh-arrow .arrow-hit { pointer-events: stroke; cursor: move; }
.stage.editing .sh-arrow .end { fill: #fff; stroke: var(--sh-color, var(--brand)); stroke-width: 2; cursor: grab; display: none; pointer-events: none; }
.stage.editing .sh-arrow.is-selected .end { display: block; pointer-events: all; }

.sh-text {
  position: absolute;
  z-index: 3;
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 5px 9px;
  font-family: var(--font-ui);
  font-size: var(--tb-size, 15px);
  line-height: 1.55;
  color: var(--tb-color, var(--ink));
  box-shadow: 0 4px 14px rgba(20, 21, 26, 0.16);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-width: 40px;
  outline: none;
}
.stage.editing .sh-text { cursor: move; }
.stage.editing .sh-text.is-editing { cursor: text; box-shadow: 0 0 0 3px var(--brand-s2), 0 4px 14px rgba(20, 21, 26, 0.16); }
.stage.editing .sh-highlight.is-selected,
.stage.editing .sh-text.is-selected { outline: 2.5px solid color-mix(in srgb, var(--accent) 85%, transparent); outline-offset: 2px; }

.stage.tool-marker .overlay { cursor: crosshair; }
.stage.tool-highlight .overlay,
.stage.tool-arrow .overlay { cursor: crosshair; }
.stage.tool-text .overlay { cursor: text; }

/* ============================== animations ============================== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes stageIn { from { opacity: 0; transform: scale(var(--stage-scale)) translateY(10px); } to { opacity: 1; transform: scale(var(--stage-scale)); } }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes popIn { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes mkPop { 0% { transform: translate(-50%, -50%) scale(0.4); } 70% { transform: translate(-50%, -50%) scale(1.15); } 100% { transform: translate(-50%, -50%) scale(1); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ============================== responsive floor ============================== */
@media (max-width: 1240px) {
  .workspace { grid-template-columns: 214px minmax(0, 1fr) 296px; }
  .tool span { display: none; }
  .tool { padding: 0 9px; }
}
@media (max-width: 1000px) {
  .workspace { grid-template-columns: 190px minmax(0, 1fr); }
  .inspector { display: none; }
  .topbar-title { display: none; }
}
