/* ════════════════════════════════════════════════════════════════
   ذهن‌نگار — استایل اصلی
   ════════════════════════════════════════════════════════════════ */

/* ─────────────── فونت وزیرمتن (محلی) ─────────────── */
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn-ExtraBold.woff2') format('woff2'); font-weight: 800; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn-Black.woff2') format('woff2'); font-weight: 900; font-display: swap; }

:root {
  --font: 'Vazirmatn', Vazir, Tahoma, 'Segoe UI', sans-serif;
  --bg: #f4f6fb;
  --bg2: #e9edf7;
  --surface: #ffffff;
  --surface-2: #f1f4fa;
  --text: #1e2434;
  --text-2: #5b6478;
  --border: #e2e7f2;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-grad: linear-gradient(135deg, #6366f1, #8b5cf6 60%, #d946ef);
  --danger: #ef4444;
  --ok: #22c55e;
  --shadow: 0 10px 30px rgba(30, 36, 52, .08), 0 2px 8px rgba(30, 36, 52, .05);
  --shadow-lg: 0 24px 60px rgba(30, 36, 52, .16);
  --radius: 14px;
  --toolbar-h: 54px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0d1220;
  --bg2: #0a0e1a;
  --surface: #161c2e;
  --surface-2: #1d2438;
  --text: #e8ecf6;
  --text-2: #97a1b8;
  --border: #283048;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35), 0 2px 8px rgba(0, 0, 0, .25);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; color: inherit; }
::selection { background: rgba(99, 102, 241, .25); }

/* ─────────────── animated background ─────────────── */
.bg-decor { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.bg-decor .blob {
  position: absolute; border-radius: 50%; filter: blur(90px); opacity: .5;
  animation: blobFloat 22s ease-in-out infinite alternate;
}
html[data-theme="dark"] .bg-decor .blob { opacity: .22; }
.blob.b1 { width: 480px; height: 480px; background: #818cf8; top: -140px; right: -100px; }
.blob.b2 { width: 420px; height: 420px; background: #f0abfc; bottom: -160px; left: -120px; animation-delay: -7s; }
.blob.b3 { width: 360px; height: 360px; background: #67e8f9; top: 38%; left: 30%; animation-delay: -14s; }
@keyframes blobFloat {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-46px, 32px) scale(1.08); }
  100% { transform: translate(38px, -28px) scale(.95); }
}
.bg-grid {
  position: absolute; inset: 0; opacity: .5;
  background-image: radial-gradient(circle at 1px 1px, var(--border) 1px, transparent 1.4px);
  background-size: 26px 26px;
  mask-image: radial-gradient(ellipse 90% 80% at 50% 40%, black 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 90% 80% at 50% 40%, black 30%, transparent 75%);
}

/* ─────────────── generic bits ─────────────── */
.view { position: relative; z-index: 1; height: 100vh; }
[hidden] { display: none !important; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: 11px; font-size: 14px; font-weight: 600;
  transition: transform .15s, box-shadow .15s, background .15s, opacity .15s;
  user-select: none;
}
.btn:active { transform: scale(.96); }
.btn-primary { background: var(--accent-grad); color: #fff; box-shadow: 0 6px 18px rgba(99, 102, 241, .35); }
.btn-primary:hover { box-shadow: 0 8px 24px rgba(99, 102, 241, .5); transform: translateY(-1px); }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-lg { padding: 12px 22px; font-size: 15px; border-radius: 13px; }
.btn-block { width: 100%; justify-content: center; }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 9px; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 14px; border-radius: 11px; border: 1.5px solid var(--border);
  background: var(--surface); font-size: 14px; outline: none; transition: border .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 4px rgba(99, 102, 241, .15);
}
.form-error {
  background: rgba(239, 68, 68, .1); color: var(--danger);
  border: 1px solid rgba(239, 68, 68, .3); border-radius: 10px;
  padding: 9px 13px; font-size: 13px; margin-bottom: 12px;
}

.toasts { position: fixed; bottom: 22px; right: 50%; transform: translateX(50%); z-index: 3000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--text); color: var(--bg); padding: 10px 20px; border-radius: 12px;
  font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease, toastOut .3s ease 2.6s forwards; max-width: 420px; text-align: center;
}
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: #0e9f5d; color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px); } }

/* ─────────────── AUTH ─────────────── */
.auth-wrap {
  display: grid; grid-template-columns: 1.1fr 1fr; align-items: center;
  max-width: 1120px; margin: 0 auto; padding: 32px; gap: 48px;
}
.auth-hero h1 {
  font-size: 52px; font-weight: 900; line-height: 1.25;
  background: linear-gradient(120deg, #6366f1, #a855f7, #ec4899);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.auth-logo-big { margin-bottom: 14px; filter: drop-shadow(0 8px 20px rgba(99, 102, 241, .35)); animation: floatY 5s ease-in-out infinite; }
@keyframes floatY { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
.hero-sub { font-size: 16.5px; color: var(--text-2); line-height: 2; max-width: 440px; margin-top: 10px; }
.hero-points { list-style: none; margin-top: 26px; display: grid; gap: 12px; }
.hero-points li { display: flex; align-items: center; gap: 10px; font-size: 14.5px; font-weight: 500; color: var(--text); }
.hero-points .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--accent)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 20%, transparent); }

.auth-panel { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.auth-card {
  width: min(410px, 92vw); background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px); border: 1px solid var(--border); border-radius: 22px;
  padding: 28px; box-shadow: var(--shadow-lg);
  animation: cardUp .45s ease;
}
@keyframes cardUp { from { opacity: 0; transform: translateY(18px); } }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 12px; padding: 4px; margin-bottom: 22px; }
.auth-tab { padding: 9px; border-radius: 9px; font-size: 14px; font-weight: 700; color: var(--text-2); transition: all .2s; }
.auth-tab.active { background: var(--surface); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.09); }
.auth-foot { font-size: 13px; color: var(--text-2); }
.auth-title { font-size: 17px; margin-bottom: 16px; text-align: center; }
.auth-contact {
  margin-top: 16px; padding: 12px 14px; border-radius: 12px;
  background: var(--surface-2); border: 1px dashed var(--border);
  font-size: 13px; color: var(--text-2); line-height: 2; text-align: center;
  display: grid; gap: 3px;
}
.contact-number { font-weight: 800; font-size: 16px; color: var(--accent); text-decoration: none; }
.contact-number:hover { text-decoration: underline; }

/* فرم ورود: چشم گذرواژه */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-inline-end: 40px !important; }
.pw-eye {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  color: var(--text-2); background: none; border: none;
}
.pw-eye:hover { color: var(--accent); background: var(--surface-2); }

/* حالت لینک اشتراک: ابزارهای ویرایشی مخفی */
.editor-wrap.share-mode .tb-share-hide,
.editor-wrap.share-mode .share-hide { display: none !important; }

/* کارت نقشه: نشان اشتراک فعال */
.shared-chip { background: rgba(34, 197, 94, .14); color: #16a34a; border-radius: 99px; padding: 2px 9px; font-size: 11px; font-weight: 700; }

/* مودال اشتراک و پنل مدیریت */
.share-desc { font-size: 13px; color: var(--text-2); line-height: 1.9; margin-bottom: 12px; }
.form-ok {
  margin-top: 10px; padding: 10px 12px; border-radius: 10px;
  background: rgba(34, 197, 94, .1); border: 1px solid rgba(34, 197, 94, .35);
  color: #15803d; font-size: 12.5px; line-height: 2; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.share-box input[readonly] { background: var(--surface-2); font-size: 12.5px; }
.admin-modal { width: min(640px, 94vw); }
.admin-create { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; margin-bottom: 16px; }
.admin-create > b { font-size: 13.5px; display: block; margin-bottom: 10px; }
.admin-form { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 10px; align-items: end; }
.admin-form .field { margin-bottom: 0; }
.admin-list { margin-top: 10px; display: grid; gap: 6px; max-height: 260px; overflow-y: auto; }
.admin-row {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 12px;
}
.admin-avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 14px; flex-shrink: 0;
}
.admin-info { flex: 1; min-width: 0; display: grid; }
.admin-info b { font-size: 13.5px; }
.admin-info span { font-size: 11.5px; color: var(--text-2); }
.role-badge {
  background: rgba(245, 158, 11, .15); color: #d97706; border-radius: 99px;
  font-size: 10px; padding: 1px 8px; margin-inline-start: 5px;
}
.admin-acts { display: flex; gap: 4px; }
.admin-acts button {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  color: var(--text-2); font-size: 14px;
}
.admin-acts button:hover { background: var(--surface-2); color: var(--text); }
.admin-acts button:last-child:hover { color: var(--danger); }
@media (max-width: 640px) {
  .admin-form { grid-template-columns: 1fr; }
}

@media (max-width: 880px) {
  .auth-wrap { grid-template-columns: 1fr; padding: 20px; gap: 26px; }
  .auth-hero h1 { font-size: 36px; }
  .auth-hero { text-align: center; }
  .hero-sub { margin-inline: auto; }
  .hero-points { justify-items: center; }
}

/* ─────────────── DASHBOARD ─────────────── */
.dash-wrap { display: flex; flex-direction: column; }
.dash-topbar {
  display: flex; align-items: center; gap: 18px; padding: 12px 26px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.dash-brand { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 800; }
.dash-search {
  flex: 1; max-width: 420px; display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1.5px solid var(--border); border-radius: 12px; padding: 8px 14px; color: var(--text-2);
}
.dash-search:focus-within { border-color: var(--accent); }
.dash-search input { border: none; outline: none; background: none; width: 100%; font-size: 14px; }
.dash-actions { display: flex; align-items: center; gap: 10px; margin-inline-start: auto; }

.user-chip { position: relative; display: flex; align-items: center; gap: 9px; padding: 5px 10px; border-radius: 12px; cursor: pointer; font-size: 13.5px; font-weight: 600; border: 1px solid var(--border); background: var(--surface); }
.user-chip:hover, .user-chip:focus { background: var(--surface-2); outline: none; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-grad); color: #fff; font-size: 14px; font-weight: 800; flex-shrink: 0;
}
.user-menu {
  position: absolute; top: calc(100% + 8px); left: 0; min-width: 190px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 13px;
  box-shadow: var(--shadow-lg); padding: 6px; display: grid; opacity: 0; visibility: hidden; transform: translateY(-6px); transition: all .18s;
}
.user-chip:hover .user-menu, .user-chip:focus .user-menu, .user-chip:focus-within .user-menu { opacity: 1; visibility: visible; transform: none; }
.user-menu button { text-align: right; padding: 9px 12px; border-radius: 9px; font-size: 13.5px; font-weight: 500; width: 100%; }
.user-menu button:hover { background: var(--surface-2); }
.user-menu button.danger { color: var(--danger); }

.dash-main { flex: 1; overflow-y: auto; padding: 28px 30px 60px; }
.dash-head-row { display: flex; align-items: center; justify-content: space-between; max-width: 1280px; margin: 0 auto 20px; }
.dash-head-row h2 { font-size: 22px; font-weight: 800; }
.count-badge { background: var(--accent); color: #fff; font-size: 12px; padding: 2px 10px; border-radius: 99px; margin-inline-start: 6px; }
.dash-sort label { font-size: 13px; color: var(--text-2); }
.dash-sort select { padding: 7px 11px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface); margin-inline-start: 6px; font-size: 13px; outline: none; }

.maps-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 20px; max-width: 1280px; margin: 0 auto;
}
.map-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px; overflow: hidden;
  box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s; cursor: pointer; position: relative;
  animation: cardUp .4s ease backwards;
}
.map-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.map-thumb { height: 130px; position: relative; display: grid; place-items: center; overflow: hidden; }
.map-thumb svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-title {
  padding: 13px 16px 4px; font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.map-meta { padding: 2px 16px 14px; display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 12.5px; flex-wrap: wrap; }
.map-meta .chip { background: var(--surface-2); border-radius: 99px; padding: 2px 9px; font-size: 11.5px; }
.map-actions {
  position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; opacity: 0; transition: opacity .18s;
}
.map-card:hover .map-actions { opacity: 1; }
.map-actions button {
  width: 32px; height: 32px; border-radius: 9px; background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(6px); border: 1px solid var(--border); display: grid; place-items: center; font-size: 14px;
}
.map-actions button:hover { background: var(--surface); transform: scale(1.06); }
.map-actions button.danger:hover { color: var(--danger); }

.maps-empty { text-align: center; padding: 60px 20px; color: var(--text-2); display: grid; gap: 14px; justify-items: center; }
.maps-empty h3 { color: var(--text); font-size: 21px; }

/* ─────────────── EDITOR ─────────────── */
.editor-wrap { display: flex; flex-direction: column; height: 100vh; background: var(--canvas-bg, #f6f7fb); }
.ed-topbar {
  min-height: var(--toolbar-h); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 4px 12px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border); z-index: 40;
}
.ed-group { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.ed-group .divider { width: 1px; height: 26px; background: var(--border); margin: 0 4px; }

.ed-title {
  border: 1.5px solid transparent; background: transparent; font-size: 14.5px; font-weight: 800; width: 168px;
  padding: 6px 9px; border-radius: 9px; outline: none; color: var(--text);
}
.ed-title:hover { border-color: var(--border); }
.ed-title:focus { border-color: var(--accent); background: var(--surface); }

.save-status { font-size: 11.5px; color: var(--text-2); display: flex; align-items: center; gap: 5px; min-width: 68px; }
.save-status .ss-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); transition: background .2s; }
.save-status.saving .ss-dot { background: #f59e0b; animation: pulse 1s infinite; }
.save-status.error .ss-dot { background: var(--danger); }
@keyframes pulse { 50% { opacity: .3; } }

.tb-icon {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--text-2);
  transition: all .15s; flex-shrink: 0; font-size: 15px;
}
.tb-icon:hover { background: var(--surface-2); color: var(--text); }
.tb-icon:disabled { opacity: .35; pointer-events: none; }
.tb-icon.active { background: rgba(99, 102, 241, .14); color: var(--accent); }
.tb-icon.sm { width: 30px; height: 30px; border-radius: 8px; font-size: 14px; }
.tb-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 10px;
  font-size: 13px; font-weight: 600; color: var(--text-2); transition: all .15s; flex-shrink: 0;
}
.tb-btn:hover { background: var(--surface-2); color: var(--text); }
.tb-btn.accent { color: var(--accent); }
.tb-btn.accent:hover { background: rgba(99, 102, 241, .12); }
.tb-select {
  padding: 7px 8px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface);
  font-size: 12.5px; font-weight: 600; outline: none; cursor: pointer; max-width: 118px;
}
.zoom-ctrl { display: flex; align-items: center; background: var(--surface-2); border-radius: 11px; padding: 2px; }
.zoom-val { min-width: 52px; text-align: center; font-size: 12.5px; font-weight: 700; padding: 4px; border-radius: 8px; }
.zoom-val:hover { background: var(--surface); }

.tb-menu-wrap { position: relative; }
.tb-menu {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 180px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 13px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 60;
  opacity: 0; visibility: hidden; transform: translateY(-6px); transition: all .18s;
}
.tb-menu-wrap.open .tb-menu { opacity: 1; visibility: visible; transform: none; }
.tb-menu button { display: block; width: 100%; text-align: right; padding: 9px 12px; border-radius: 9px; font-size: 13.5px; font-weight: 500; }
.tb-menu button:hover { background: var(--surface-2); }

/* canvas */
.ed-canvas { flex: 1; position: relative; overflow: hidden; touch-action: none; cursor: default; }
.ed-canvas.panning { cursor: grabbing; }
.ed-canvas.crosshair { cursor: crosshair; }
#mm-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; user-select: none; }

.mm-edit {
  position: absolute; z-index: 30; font-family: var(--font); font-weight: 600; text-align: center;
  border: 2.5px solid var(--accent); border-radius: 12px; outline: none; background: var(--surface);
  box-shadow: 0 8px 30px rgba(99, 102, 241, .3); padding: 8px 14px; direction: rtl;
}

/* SVG node visuals */
.node-g { cursor: pointer; }
.node-g.dragging { opacity: .75; cursor: grabbing; }
.node-g .sel-ring { fill: none; stroke: transparent; stroke-width: 2.5; }
.node-g.selected .sel-ring { stroke: #6366f1; stroke-dasharray: 7 5; animation: dashMove 20s linear infinite; }
.node-g.drop-target rect.body, .node-g.drop-target ellipse.body { stroke: #6366f1 !important; stroke-width: 3 !important; filter: drop-shadow(0 0 6px rgba(99,102,241,.7)); }
@keyframes dashMove { to { stroke-dashoffset: -200; } }
.node-g text { pointer-events: none; }
.collapse-btn { cursor: pointer; }
.collapse-btn circle { transition: r .15s; }
.collapse-btn:hover circle { r: 12; }
.edge { pointer-events: none; }

/* style panel */
.style-panel {
  position: absolute; z-index: 35; background: var(--surface); border: 1px solid var(--border);
  border-radius: 15px; box-shadow: var(--shadow-lg); padding: 13px 15px; display: grid; gap: 11px;
  animation: panelIn .18s ease; max-width: 280px;
}
@keyframes panelIn { from { opacity: 0; transform: translateY(8px); } }
.sp-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sp-label { font-size: 12px; font-weight: 700; color: var(--text-2); min-width: 58px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 24px; height: 24px; border-radius: 8px; border: 2px solid transparent; transition: transform .12s; }
.swatch:hover { transform: scale(1.15); }
.swatch.selected { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface) inset; }
.sp-tools { display: flex; gap: 6px; }
.sp-btn { width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); font-size: 16px; display: grid; place-items: center; transition: all .13s; }
.sp-btn:hover { background: var(--border); transform: scale(1.07); }

/* emoji picker */
.emoji-picker {
  position: absolute; z-index: 45; width: 316px; max-height: 320px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 15px; box-shadow: var(--shadow-lg);
  padding: 12px; animation: panelIn .18s ease;
}
.emoji-cat { font-size: 12px; font-weight: 700; color: var(--text-2); margin: 8px 2px 6px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-grid button { font-size: 19px; padding: 5px; border-radius: 8px; transition: background .1s, transform .1s; }
.emoji-grid button:hover { background: var(--surface-2); transform: scale(1.2); }

/* note / link editor */
.note-editor {
  position: absolute; z-index: 45; width: 300px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 15px; box-shadow: var(--shadow-lg); padding: 14px; display: grid; gap: 9px; animation: panelIn .18s ease;
}
.ne-title { font-size: 12.5px; font-weight: 800; color: var(--text-2); }
.note-editor textarea, .note-editor input {
  width: 100%; border: 1.5px solid var(--border); background: var(--surface-2); border-radius: 10px;
  padding: 9px 11px; font-size: 13.5px; outline: none; resize: vertical; direction: rtl;
}
.note-editor textarea:focus, .note-editor input:focus { border-color: var(--accent); }
.ne-actions { display: flex; justify-content: space-between; }

/* context menu */
.ctx-menu {
  position: fixed; z-index: 80; min-width: 210px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; animation: panelIn .15s ease;
}
.ctx-menu button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: right; padding: 9px 12px; border-radius: 9px; font-size: 13.5px; font-weight: 500; }
.ctx-menu button:hover { background: var(--surface-2); }
.ctx-menu button.danger { color: var(--danger); }
.ctx-menu .ctx-sep { height: 1px; background: var(--border); margin: 5px 8px; }
.ctx-menu .ctx-swatches { display: flex; flex-wrap: wrap; gap: 5px; padding: 6px 12px 9px; }
.ctx-menu kbd { margin-inline-start: auto; font-size: 10.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; color: var(--text-2); }

/* find bar */
.find-bar {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 38;
  display: flex; align-items: center; gap: 5px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 13px; box-shadow: var(--shadow-lg); padding: 5px 8px; animation: panelIn .18s ease;
}
.find-bar input { border: none; outline: none; background: none; font-size: 13.5px; width: 200px; padding: 4px 8px; }
.find-count { font-size: 12px; color: var(--text-2); white-space: nowrap; }

/* minimap */
.minimap {
  position: absolute; bottom: 14px; left: 14px; z-index: 32; width: 178px; height: 122px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(6px);
  border: 1px solid var(--border); border-radius: 13px; box-shadow: var(--shadow); overflow: hidden; cursor: pointer;
}
#minimap-svg { width: 100%; height: 100%; display: block; }

.ed-float-bottom { position: absolute; bottom: 14px; right: 50%; transform: translateX(50%); z-index: 30; display: flex; gap: 8px; }
.stats-chip {
  background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(6px);
  border: 1px solid var(--border); border-radius: 99px; padding: 6px 15px; font-size: 12px; font-weight: 600; color: var(--text-2);
}

/* outline drawer */
.outline-drawer {
  position: absolute; top: 0; left: 0; bottom: 0; width: 330px; z-index: 36;
  background: color-mix(in srgb, var(--surface) 96%, transparent); backdrop-filter: blur(10px);
  border-right: 1px solid var(--border); box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  animation: slideIn .22s ease;
}
@keyframes slideIn { from { transform: translateX(-30px); opacity: 0; } }
.od-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.od-head b { font-size: 14.5px; }
.od-body { flex: 1; overflow-y: auto; padding: 10px 8px 30px; }
.od-item { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 8px; font-size: 13.5px; cursor: pointer; border: 1px solid transparent; }
.od-item:hover { background: var(--surface-2); }
.od-item.selected { border-color: var(--accent); background: rgba(99, 102, 241, .08); }
.od-item .od-dot { width: 9px; height: 9px; border-radius: 4px; flex-shrink: 0; }
.od-item .od-txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; font-weight: 500; }
.od-item .od-ic { font-size: 13px; }
.od-item input { flex: 1; font-size: 13px; border: 1.5px solid var(--accent); border-radius: 6px; padding: 2px 7px; outline: none; background: var(--surface); min-width: 0; }
.od-empty { color: var(--text-2); font-size: 12px; padding-inline: 12px; }

/* presentation */
.present-overlay { position: absolute; inset: 0; z-index: 90; background: radial-gradient(1200px 700px at 50% 40%, #10162b, #05070f); animation: fadeIn .4s ease; }
@keyframes fadeIn { from { opacity: 0; } }
.present-hint {
  position: absolute; bottom: 22px; right: 50%; transform: translateX(50%); display: flex; gap: 22px;
  color: #ffffffaa; font-size: 13px; z-index: 95; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
  padding: 8px 20px; border-radius: 99px; backdrop-filter: blur(6px);
}
.present-level {
  position: absolute; top: 18px; right: 20px; color: #ffffff88; font-size: 13px; z-index: 95;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); padding: 6px 15px; border-radius: 99px;
}

/* ─────────────── modals ─────────────── */
.modal-back {
  position: fixed; inset: 0; z-index: 2000; background: rgba(10, 14, 26, .45); backdrop-filter: blur(5px);
  display: grid; place-items: center; padding: 20px; animation: fadeIn .2s ease;
}
.modal {
  width: min(560px, 94vw); max-height: 88vh; overflow-y: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: 20px; padding: 26px; box-shadow: var(--shadow-lg);
  animation: cardUp .25s ease;
}
.modal.slim { width: min(400px, 94vw); }
.modal h3 { font-size: 18px; margin-bottom: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 9px; }
.tpl-item {
  border: 2px solid var(--border); border-radius: 13px; padding: 11px 13px; text-align: right; transition: all .15s;
  display: grid; gap: 3px; background: var(--surface-2);
}
.tpl-item:hover { border-color: #b6bcf5; }
.tpl-item.selected { border-color: var(--accent); background: rgba(99, 102, 241, .08); }
.tpl-item b { font-size: 13.5px; }
.tpl-item span { font-size: 11.5px; color: var(--text-2); }

.theme-grid { display: flex; flex-wrap: wrap; gap: 9px; }
.theme-item { display: grid; gap: 5px; justify-items: center; font-size: 11.5px; font-weight: 600; color: var(--text-2); }
.theme-item .ti-dots { display: flex; gap: 3px; padding: 6px; border: 2px solid var(--border); border-radius: 99px; transition: all .15s; }
.theme-item:hover .ti-dots { border-color: #b6bcf5; }
.theme-item.selected .ti-dots { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.ti-dots i { width: 15px; height: 15px; border-radius: 50%; }

.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.help-cols h4 { font-size: 14px; margin-bottom: 10px; color: var(--accent); }
.help-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.help-table td { padding: 7px 4px; border-bottom: 1px solid var(--border); color: var(--text-2); }
.help-table td:first-child { color: var(--text); font-weight: 600; white-space: nowrap; }
kbd { font-family: inherit; }

/* ─────────────── editor extras ─────────────── */

/* پاپ‌اورهای ادیتور با جاوااسکریپت نزدیک نود انتخابی جای‌گذاری می‌شوند */
.style-panel, .emoji-picker, .note-editor {
  top: 70px;
  left: 14px;
}

/* دکمه‌های شکل نود در پنل ابزار */
.shape-btns { display: flex; gap: 5px; }

/* پاپ‌آور Show Detail */
.detail-pop {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 70;
  background: var(--surface); border: 1px solid var(--border); border-radius: 13px;
  box-shadow: var(--shadow-lg); padding: 12px 14px; width: 236px;
  opacity: 0; visibility: hidden; transform: translateY(-6px); transition: all .18s;
}
.detail-pop:not([hidden]) { opacity: 1; visibility: visible; transform: none; }
.dp-title { display: block; font-size: 12.5px; font-weight: 800; color: var(--text-2); margin-bottom: 9px; }
.dp-row { display: flex; align-items: center; gap: 10px; }
.dp-row input[type=range] { flex: 1; accent-color: var(--accent); cursor: pointer; }
.dp-val { min-width: 52px; text-align: center; font-size: 12px; font-weight: 800; color: var(--accent); }

/* حالت نمایش (Focus Mode) — منوها جمع، فقط بوم */
.editor-wrap.focus-mode .ed-topbar,
.editor-wrap.focus-mode .ed-float-bottom,
.editor-wrap.focus-mode .minimap { display: none !important; }
.focus-exit {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(6px);
  border: 1px solid var(--border); border-radius: 99px; padding: 7px 18px;
  font-size: 12.5px; font-weight: 700; color: var(--text-2); box-shadow: var(--shadow);
  transition: color .15s, border-color .15s;
}
.focus-exit:hover { color: var(--danger); border-color: var(--danger); }
.shape-btn {
  width: 38px; height: 30px; border-radius: 9px; background: var(--surface-2);
  display: grid; place-items: center; color: var(--text-2); transition: all .13s;
}
.shape-btn:hover { background: var(--border); transform: scale(1.06); }
.shape-btn.selected { background: rgba(99, 102, 241, .15); color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.shape-btn svg { display: block; }

/* دکمه‌های عملیات نمای فهرستی */
.od-acts { display: none; gap: 2px; flex-shrink: 0; }
.od-item:hover .od-acts { display: flex; }
.od-acts button {
  width: 22px; height: 22px; border-radius: 6px; font-size: 11.5px; line-height: 1;
  display: grid; place-items: center; color: var(--text-2);
}
.od-acts button:hover { background: var(--border); color: var(--text); }
.od-acts button:last-child:hover { color: var(--danger); }

/* شکل‌ها در منوی راست‌کلیک */
.ctx-shapes { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 12px 8px; }
.ctx-shapes button {
  font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 99px;
  background: var(--surface-2); color: var(--text-2);
}
.ctx-shapes button:hover { background: rgba(99, 102, 241, .15); color: var(--accent); }

/* هایلایت نتیجه جست‌وجو */
.node-g.found .sel-ring { stroke: #f59e0b; stroke-dasharray: none; stroke-width: 3; }
.node-g.found.selected .sel-ring { stroke: #6366f1; }

/* شبح درگ شاخه */
.mm-ghost {
  position: fixed; z-index: 5000; pointer-events: none;
  background: var(--surface); color: var(--text);
  border: 2.5px solid var(--accent); border-radius: 99px;
  padding: 6px 16px; font-size: 13.5px; font-weight: 700;
  box-shadow: 0 10px 30px rgba(99, 102, 241, .35); white-space: nowrap;
}

/* SVG داخل حالت ارائه */
.present-overlay svg { position: absolute; inset: 0; width: 100%; height: 100%; }

@media (max-width: 760px) {
  .style-panel, .emoji-picker, .note-editor { max-width: calc(100vw - 28px); }
}

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; border: 2.5px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-2); background-clip: content-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 760px) {
  .dash-topbar { flex-wrap: wrap; padding: 10px 14px; }
  .dash-search { order: 3; min-width: 100%; }
  .ed-title { width: 130px; }
  .help-cols { grid-template-columns: 1fr; }
}
