/* ── CSS variables (overridden at runtime by applyTreePrefs()) ── */
:root {
  --tree-fg:          #1a1a1a;
  --tree-bg:          #ffffff;
  --tree-font-size:   12px;
  --tree-font-family: system-ui, -apple-system, sans-serif;
  --cut-fg:           #ffffff;
  --cut-bg:           #5b8dd9;
}

/* ── Reset & base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: system-ui, -apple-system, sans-serif; font-size: 13px; background: #f0f2f5; color: #1a1a1a; }

/* ── App shell ────────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ── Export dropdown ──────────────────────────────────────────── */
.tb-dropdown-wrap { position: relative; }
.tb-dropdown-btn { display: flex; align-items: center; gap: 4px; }
.tb-chevron { flex-shrink: 0; }
.tb-spacer { flex: 1; display: flex; justify-content: center; align-items: center; }
.tb-filename { font-size: 12px; color: #555; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-filename.dirty::after { content: ' •'; color: #cc5500; font-size: 15px; line-height: 1; }
.tb-dropdown {
  display: none; position: absolute; top: calc(100% + 4px); left: 0;
  background: #2c2c2e; border: 1px solid #3a3a3c;
  border-radius: 6px; min-width: 200px; padding: 4px 0;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 300;
}
.tb-dropdown.open { display: block; }
.menu-action {
  padding: 6px 14px; cursor: default; display: flex;
  align-items: center; gap: 8px;
  color: #f5f5f5; font-size: 13px;
}
.menu-action > span:last-child:not(.mi-icon):not(.shortcut) { flex: 1; }
.menu-action .shortcut { color: #888; font-size: 11px; margin-left: auto; }
.menu-action:hover .shortcut { color: rgba(255,255,255,0.7); }
.menu-action:hover:not(.disabled) { background: #0a84ff; border-radius: 4px; margin: 0 4px; padding: 6px 10px; }
.menu-action.disabled { color: #666; cursor: default; }
.mi-icon {
  width: 16px; height: 16px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.mi-icon svg { width: 16px; height: 16px; display: block; }
.menu-sep { height: 1px; background: #3a3a3c; margin: 4px 0; }
.shortcut { color: #888; font-size: 11px; }

/* ── Toolbar ──────────────────────────────────────────────────── */
#toolbar {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  background: #f2f2f7; border-bottom: 1px solid #d1d1d6;
  flex-shrink: 0;
}
.tb-btn {
  padding: 5px 7px; border: 1px solid #c6c6c8;
  border-radius: 5px; background: #fff; cursor: pointer;
  color: #1a1a1a; line-height: 0;
  transition: background 0.1s;
  display: flex; align-items: center; justify-content: center;
}
.tb-btn svg { width: 16px; height: 16px; display: block; }
.tb-btn:hover:not(:disabled) { background: #e9e9ec; }
.tb-btn:active:not(:disabled) { background: #d1d1d6; }
.tb-btn:disabled { opacity: 0.38; cursor: default; }
.tb-sep { width: 1px; height: 20px; background: #c6c6c8; margin: 0 4px; }
.tb-zoom-level {
  font-size: 11px; color: #555; min-width: 38px; text-align: center;
  font-variant-numeric: tabular-nums; cursor: pointer; user-select: none;
  padding: 3px 4px; border-radius: 4px;
}
.tb-zoom-level:hover { background: #e9e9ec; color: #1a1a1a; }

/* ── Main split ───────────────────────────────────────────────── */
#main { display: flex; flex: 1; overflow: hidden; }

/* ── Sidebar ──────────────────────────────────────────────────── */
#sidebar {
  flex-shrink: 0;
  background: #fff;
  display: flex; flex-direction: column; overflow: hidden;
  min-width: 120px; max-width: 600px;
}

/* ── Split handle ─────────────────────────────────────────────── */
#split-handle {
  width: 5px; flex-shrink: 0;
  background: #d1d1d6;
  cursor: col-resize;
  transition: background 0.15s;
  position: relative;
}
#split-handle:hover, #split-handle.dragging { background: #0a84ff; }
#split-handle::after {
  content: '';
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 1px; height: 32px;
  background: rgba(255,255,255,0.6);
  border-radius: 1px;
}
#sidebar-tabs {
  display: flex; flex-shrink: 0;
  border-bottom: 1px solid #e8e8ed;
}
.tab-btn {
  flex: 1; padding: 8px 4px; background: transparent; border: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: #999; cursor: pointer; font-family: inherit;
  transition: color 0.12s;
}
.tab-btn:hover { color: #555; }
.tab-btn.active { color: #0a84ff; border-bottom-color: #0a84ff; }

#tree-container { flex: 1; overflow-y: auto; padding: 4px 0; }

#json-editor-container {
  display: none; flex: 1; overflow: hidden; flex-direction: column;
}
#json-editor-container .CodeMirror {
  height: 100%; font-size: 12px;
  font-family: ui-monospace, Menlo, monospace;
}
#json-editor-container .CodeMirror-scroll { overflow: auto !important; }
.json-locked {
  flex: 1; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #aaa; font-style: italic; user-select: none;
}

/* ── Tree rows ────────────────────────────────────────────────── */
.tree-row {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 8px; cursor: default; border-radius: 4px; margin: 1px 4px;
  color: var(--tree-fg); background: var(--tree-bg);
  font-family: var(--tree-font-family);
}
.tree-row:hover { background: #f2f2f7; }
.tree-row.selected { background: #e1f0ff !important; color: #0a5dcd !important; }
.tree-row.selected:hover { background: #cce4ff !important; }
.tree-row.cut { color: var(--cut-fg) !important; background: var(--cut-bg) !important; }
.tree-toggle {
  font-size: 10px; width: 14px; text-align: center;
  color: #888; flex-shrink: 0; cursor: pointer;
}
.tree-row.selected .tree-toggle { color: #0a5dcd; }
.tree-toggle:hover { color: #333; }
.tree-label { font-size: var(--tree-font-size); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Chart area ───────────────────────────────────────────────── */
#chart-area { flex: 1; overflow: auto; background: #f9f9fb; position: relative; }
#chart-svg  { display: block; cursor: default; }

/* ── Modals ───────────────────────────────────────────────────── */
.hidden { display: none !important; }

#modal-overlay, #style-overlay, #help-overlay, #about-overlay, #layout-overlay, #pasteattrs-overlay, #settings-overlay, #legend-overlay,
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
}
#modal, #style-modal, #help-modal, #about-modal, #layout-modal, #pasteattrs-modal, #settings-modal, #legend-modal,
.overlay .modal {
  background: #fff; border-radius: 12px;
  padding: 24px; min-width: 340px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
#help-modal { min-width: 440px; }
#about-modal { min-width: 300px; text-align: center; }
.help-section {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.6px; color: #888;
  margin: 14px 0 6px; padding-bottom: 4px;
  border-bottom: 1px solid #e8e8ed;
}
.help-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.help-table td { padding: 4px 6px; vertical-align: top; }
.help-table td:first-child { color: #555; width: 180px; white-space: nowrap; font-family: ui-monospace, monospace; font-size: 12px; }
.help-note { margin-top: 14px; font-size: 12px; color: #888; }
.about-icon { margin-bottom: 12px; }
.about-appname { font-size: 20px !important; font-weight: 700; color: #1a1a1a; margin-bottom: 4px; }
.about-sub { color: #555; font-size: 13px; margin: 4px 0 14px; }
.about-copy { color: #aaa; font-size: 11px; margin: 12px 0 14px; }
.about-features { text-align: left; margin: 0 0 12px; padding-left: 18px; font-size: 13px; color: #444; line-height: 1.8; }
.about-links { font-size: 12px; margin-bottom: 4px; }
.about-links a { color: #0a84ff; text-decoration: none; }
.about-links a:hover { text-decoration: underline; }
.about-link-sep { color: #ccc; margin: 0 6px; }
#modal h3, #style-modal h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.form-row { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.form-row label { width: 56px; flex-shrink: 0; padding-top: 5px; color: #555; font-size: 12px; }
.form-row input, .form-row textarea, .form-row select {
  flex: 1; padding: 5px 8px; border: 1px solid #c6c6c8;
  border-radius: 6px; font-size: 13px; font-family: inherit;
  outline: none;
}
.form-row input:focus, .form-row textarea:focus, .form-row select:focus {
  border-color: #0a84ff; box-shadow: 0 0 0 2px rgba(10,132,255,0.2);
}
.form-row input[type="color"] { padding: 2px; height: 30px; cursor: pointer; }
.form-row textarea { resize: vertical; min-height: 60px; }
.modal-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
button { font-family: inherit; font-size: 13px; }
.btn-primary {
  background: #0a84ff; color: #fff; border: none;
  padding: 6px 18px; border-radius: 7px; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center;
}
.btn-primary:hover { background: #0070e0; }
.btn-secondary {
  background: #f2f2f7; color: #1c1c1e; border: 1px solid #c6c6c8;
  padding: 6px 14px; border-radius: 7px; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center;
}
.btn-secondary:hover { background: #e5e5ea; }
.modal-btns button:not(.btn-primary) {
  background: #f2f2f7; border: 1px solid #c6c6c8;
  padding: 6px 14px; border-radius: 7px; cursor: pointer;
}
.modal-btns button:not(.btn-primary):hover { background: #e5e5ea; }
#upsell-cta-enterprise {
  background: #faf4ff; color: #8e44ad;
  border: 1.5px solid #8e44ad;
}
#upsell-cta-enterprise:hover { background: #f3e8ff; }

/* ── Context menu ─────────────────────────────────────────────── */
#ctx-menu {
  position: fixed; z-index: 400;
  background: #2c2c2e; border: 1px solid #3a3a3c;
  border-radius: 8px; padding: 4px 0; min-width: 190px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.ctx-item {
  padding: 6px 14px; color: #f5f5f5; cursor: default; font-size: 13px;
  display: flex; align-items: center; gap: 8px;
}
.ctx-item:hover:not(.disabled) { background: #0a84ff; border-radius: 4px; margin: 0 4px; padding: 6px 10px; }
.ctx-item.disabled { color: #555; }
.ctx-sep { height: 1px; background: #3a3a3c; margin: 4px 0; }

/* ── Status bar ───────────────────────────────────────────────── */
#status-bar {
  padding: 4px 12px;
  background: #f2f2f7;
  border-top: 1px solid #d1d1d6;
  font-size: 12px; color: #555;
  flex-shrink: 0;
}

/* ── Preferences modal ────────────────────────────────────────── */
#prefs-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 500;
}
#prefs-modal {
  background: #fff; border-radius: 12px;
  padding: 24px 28px; min-width: 320px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
#prefs-modal h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
#prefs-modal .form-row label { width: 100px; }
.prefs-section {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.6px; color: #888;
  margin: 14px 0 8px; padding-bottom: 4px;
  border-bottom: 1px solid #e8e8ed;
}

/* ── Font Picker ──────────────────────────────────────────────── */
.fp-wrap { position: relative; display: inline-block; width: 100%; }
.fp-btn {
  width: 100%; text-align: left; padding: 5px 8px;
  border: 1px solid #c6c6c8; border-radius: 6px;
  background: #fff; cursor: pointer; font-size: 13px; font-family: inherit;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fp-btn:hover { background: #f5f5f7; }
.fp-panel {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 9999;
  background: #fff; border: 1px solid #d1d1d6; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15); width: 280px;
  display: flex; flex-direction: column; overflow: hidden;
}
.fp-hdr { padding: 8px; border-bottom: 1px solid #e8e8ed; display: flex; flex-direction: column; gap: 6px; }
.fp-search { padding: 5px 8px; border: 1px solid #c6c6c8; border-radius: 6px; font-size: 12px; font-family: inherit; outline: none; }
.fp-search:focus { border-color: #0a84ff; box-shadow: 0 0 0 2px rgba(10,132,255,0.2); }
.fp-xp { font-size: 11px; color: #555; }
.fp-list { max-height: 220px; overflow-y: auto; padding: 4px 0; }
.fp-item { padding: 6px 12px; cursor: default; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp-item:hover { background: #f2f2f7; }
.fp-item.fp-sel { background: #e1f0ff; color: #0a5dcd; }
.fp-sep { padding: 4px 12px 2px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #999; }

/* ── Font Manager ──────────────────────────────────────────────── */
.font-mgr-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; min-height: 20px; }
.font-mgr-row  { display: flex; align-items: center; gap: 6px; padding: 5px 8px; background: #f7f7fa; border-radius: 6px; font-size: 13px; }
.btn-danger    { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.btn-danger:hover { background: #fecaca; }
.btn-sm        { padding: 3px 10px; font-size: 12px; }

#settings-modal { min-width: 360px; }

/* ── Paste Attributes dialog ──────────────────────────────────── */
#pasteattrs-modal { min-width: 300px; }
.pasteattrs-sub { font-size: 12px; color: #666; margin: 0 0 4px; }
.pasteattrs-checks { display: flex; flex-direction: column; gap: 2px; margin: 10px 0 6px; }
.check-label { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; padding: 3px 0; }
.check-label input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; flex-shrink: 0; }

/* ── Page layout dialog ───────────────────────────────────────── */
#layout-modal { min-width: 320px; }
.layout-orient { display: flex; gap: 20px; padding-top: 3px; }
.radio-label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; }
.radio-label input[type="radio"] { cursor: pointer; }

/* text-color opt-in row inside style-modal */
.inline-check-color { display: flex; align-items: center; gap: 8px; padding-top: 3px; }
.inline-check-color input[type="color"] { padding: 2px; height: 28px; cursor: pointer; }

/* ── Nav drawer ───────────────────────────────────────────────── */
#nav-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.4); z-index: 498;
}
#nav-overlay.open { display: block; }

#nav-drawer {
  position: fixed; top: 0; left: 0;
  height: 100vh; height: 100dvh;
  width: 280px; max-width: 85vw;
  background: #1e2d3a; z-index: 499;
  display: flex; flex-direction: column;
  box-shadow: 4px 0 20px rgba(0,0,0,0.4);
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}
#nav-drawer.open { transform: translateX(0); }

#nav-drawer-header {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
#nav-user-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
#nav-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: #2980b9;
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
}
#nav-subject-wrap { min-width: 0; }
#nav-subject {
  font-size: 13px; color: rgba(255,255,255,0.8);
  font-weight: 500; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.nav-plan-badge {
  display: inline-block; margin-top: 4px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  padding: 1px 6px; border-radius: 4px; text-transform: uppercase;
}
.nav-plan-basic      { background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.55); }
.nav-plan-pro        { background: #f59e0b; color: #1a1000; }
.nav-plan-team       { background: #3b82f6; color: #fff; }
.nav-plan-enterprise { background: #8b5cf6; color: #fff; }
#nav-close {
  background: transparent; border: none;
  color: rgba(255,255,255,0.4); font-size: 16px;
  cursor: pointer; flex-shrink: 0; padding: 4px;
}
#nav-close:hover { color: #fff; }

#nav-menu { flex: 1; padding: 8px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 13px 20px;
  background: transparent; border: none;
  color: rgba(255,255,255,0.8); font-size: 14px;
  font-family: inherit; cursor: pointer; text-align: left;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item svg { flex-shrink: 0; opacity: 0.7; }
.nav-item:hover svg { opacity: 1; }

#nav-drawer-footer { border-top: 1px solid rgba(255,255,255,0.08); padding: 8px 0; }
.nav-signout { color: rgba(231,76,60,0.8) !important; }
.nav-signout:hover { color: #e74c3c !important; }
.nav-signin { color: rgba(10,132,255,0.9) !important; text-decoration: none; }
.nav-signin:hover { color: #0a84ff !important; }
#nav-drawer-footer form { margin: 0; }

/* ── Toast notifications ──────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 11px 18px; border-radius: 8px;
  font-size: 13px; font-weight: 500; color: #fff;
  z-index: 9000; max-width: 380px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.22);
  opacity: 0; transform: translateY(6px);
  transition: opacity 0.18s, transform 0.18s;
  pointer-events: none;
}
.toast.toast-show { opacity: 1; transform: translateY(0); }
.toast-error { background: #c0392b; }
.toast-warn  { background: #d35400; }
.toast-info  { background: #2c3e50; }

/* ── Confirm dialog ───────────────────────────────────────────── */
.confirm-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 8000;
}
.confirm-box {
  background: #fff; border-radius: 12px;
  padding: 28px 24px; min-width: 300px; max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.confirm-msg { font-size: 14px; color: #1a1a1a; line-height: 1.55; margin-bottom: 20px; }
.confirm-btns { display: flex; gap: 8px; justify-content: flex-end; }
.confirm-cancel {
  background: #f2f2f7; border: 1px solid #c6c6c8;
  padding: 6px 14px; border-radius: 7px;
  cursor: pointer; font-family: inherit; font-size: 13px;
}
.confirm-cancel:hover { background: #e5e5ea; }

/* ── File Manager dialog ──────────────────────────────────────── */
#filemgr-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 500;
}
#filemgr-modal {
  background: #fff; border-radius: 12px;
  width: 460px; max-width: 92vw; max-height: 80vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.28);
}
.filemgr-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px; border-bottom: 1px solid #e8e8ed; flex-shrink: 0;
}
.filemgr-header h3 { font-size: 15px; font-weight: 600; margin: 0; }
.filemgr-close-btn { background: none; border: none; font-size: 14px; color: #888; cursor: pointer; padding: 4px 6px; border-radius: 4px; }
.filemgr-close-btn:hover { color: #333; background: #f2f2f7; }
#filemgr-list-wrap { flex: 1; overflow-y: auto; padding: 6px 8px; min-height: 80px; }
#filemgr-empty { padding: 36px; text-align: center; color: #aaa; font-size: 13px; font-style: italic; }
.filemgr-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 7px; cursor: default; transition: background 0.1s;
}
.filemgr-row:hover { background: #f5f5f7; }
.filemgr-row.selected { background: #e1f0ff; }
.filemgr-row-info { flex: 1; min-width: 0; }
.filemgr-row-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filemgr-row-date { font-size: 11px; color: #888; margin-top: 1px; }
.filemgr-row-del {
  background: none; border: none; color: #ccc; cursor: pointer;
  padding: 4px; border-radius: 4px; flex-shrink: 0; line-height: 0;
}
.filemgr-row-del:hover { color: #c0392b; background: #fef0ee; }
.filemgr-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-top: 1px solid #e8e8ed; gap: 8px; flex-shrink: 0;
}
.filemgr-footer-left, .filemgr-footer-right { display: flex; gap: 6px; }
.filemgr-footer button:not(.btn-primary) {
  background: #f2f2f7; border: 1px solid #c6c6c8;
  padding: 5px 11px; border-radius: 7px; cursor: pointer;
  font-family: inherit; font-size: 12px; color: #1a1a1a;
}
.filemgr-footer button:not(.btn-primary):hover:not(:disabled) { background: #e5e5ea; }
.filemgr-footer button:disabled { opacity: 0.38; cursor: default; }
.btn-cloud { font-size: 11px !important; }

/* ── Legend dialog ───────────────────────────────────────────── */
#legend-modal { width: 420px; }
.legend-size-row { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.legend-size-row label { font-size: 13px; color: #555; white-space: nowrap; min-width: 32px; }
.legend-size-wrap { flex: 1; }
.legend-size-wrap input[type="range"] { width: 100%; accent-color: #0a84ff; cursor: pointer; }
.legend-size-labels { display: flex; justify-content: space-between; font-size: 11px; color: #888; margin-top: 2px; padding: 0 2px; }
.legend-rows-header { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 13px; color: #555; }
.legend-rows-header input[type="number"] { width: 52px; padding: 3px 6px; border: 1px solid #c6c6c8; border-radius: 6px; font-size: 13px; }
.legend-rows-header button { background: #f2f2f7; border: 1px solid #c6c6c8; border-radius: 6px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.legend-rows-header button:hover { background: #e5e5ea; }
.legend-row-edit { display: flex; align-items: center; gap: 6px; margin-bottom: 7px; transition: opacity .15s; }
.legend-row-edit.legend-row-dragging { opacity: 0.35; }
.legend-row-edit.legend-row-over { outline: 2px solid #0a84ff; border-radius: 6px; }
.legend-drag-handle { cursor: grab; color: #bbb; font-size: 16px; line-height: 1; flex-shrink: 0; user-select: none; padding: 0 2px; }
.legend-drag-handle:hover { color: #888; }
.legend-drag-handle:active { cursor: grabbing; }
.legend-row-edit input[type="color"] { width: 36px; height: 28px; border: 1px solid #c6c6c8; border-radius: 5px; padding: 1px 2px; cursor: pointer; flex-shrink: 0; }
.legend-row-edit input[type="text"] { flex: 1; padding: 5px 8px; border: 1px solid #c6c6c8; border-radius: 6px; font-size: 13px; }
.legend-from-node { font-size: 11px; white-space: nowrap; background: #f2f2f7; border: 1px solid #c6c6c8; border-radius: 6px; padding: 4px 8px; cursor: pointer; flex-shrink: 0; }
.legend-from-node:hover { background: #e5e5ea; }
.legend-from-node.picking { background: #fff3cd; border-color: #f0ad4e; }
.legend-row-del { background: none; border: none; color: #bbb; cursor: pointer; padding: 2px 5px; border-radius: 4px; font-size: 15px; line-height: 1; flex-shrink: 0; }
.legend-row-del:hover { color: #c0392b; background: #fef0ee; }
body.legend-picking, body.legend-picking * { cursor: crosshair !important; }

/* ── Scrollbars ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c1c1c6; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a8a8af; }

/* ── Share feature ────────────────────────────────────────────── */
.tb-share-btn { color: #0a84ff; }
.tb-share-btn:hover { background: #e8f0fe; }

/* Locked buttons in share/view mode */
.share-locked { opacity: 0.38 !important; cursor: not-allowed !important; pointer-events: auto !important; }

/* Share-mode toolbar badge and CTA */
.tb-share-badge {
  display: inline-flex; align-items: center;
  background: #ff9f0a; color: #fff;
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; padding: 2px 8px;
  border-radius: 20px; margin-left: 8px; vertical-align: middle;
}
.tb-create-own {
  display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 600; color: #0a84ff;
  padding: 4px 10px; white-space: nowrap; text-decoration: none;
  border-radius: 6px; border: 1.5px solid #0a84ff; margin-left: 4px;
  line-height: 1;
}
.tb-create-own:hover { background: #e8f0fe; }

/* Watermark for share view */
body.share-mode #chart-area::after {
  content: 'Made with Quick Org Chart';
  position: absolute; bottom: 12px; right: 16px;
  font-size: 11px; color: rgba(0,0,0,0.25); pointer-events: none;
  font-family: system-ui, sans-serif; z-index: 10;
}

/* Upsell modal */
.upsell-modal { max-width: 540px; text-align: center; }
.upsell-lock-icon { color: #636366; margin-bottom: 12px; }
.upsell-message { font-size: 14px; color: #636366; margin-bottom: 20px; }
.upsell-plans { display: flex; gap: 10px; margin-bottom: 20px; text-align: left; }
.upsell-plan {
  flex: 1; border: 1px solid #e0e0e5; border-radius: 10px;
  padding: 12px 14px; background: #f9f9fb; position: relative;
}
.upsell-plan-pro       { border-color: #0a84ff; background: #f0f6ff; }
.upsell-plan-enterprise { border-color: #8e44ad; background: #faf4ff; }
.upsell-plan-badge {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; padding: 2px 7px; border-radius: 20px;
  margin-bottom: 6px;
}
.upsell-plan-pro .upsell-plan-badge       { background: #0a84ff; color: #fff; }
.upsell-plan-enterprise .upsell-plan-badge { background: #8e44ad; color: #fff; }
.upsell-plan-name { font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.upsell-plan-perks { margin: 0; padding: 0 0 0 16px; font-size: 12px; color: #555; }
.upsell-plan-perks li { margin-bottom: 4px; }
.upsell-btns { justify-content: center; flex-wrap: wrap; gap: 8px; }
.upsell-btns a, .upsell-btns button { text-decoration: none; }

/* Share link modal */
.share-link-row { display: flex; gap: 8px; align-items: center; }
.share-link-input {
  flex: 1; padding: 7px 10px; border: 1px solid #c6c6c8; border-radius: 8px;
  font-size: 13px; background: #f2f2f7; color: #1c1c1e; font-family: monospace;
}
