/* ── VARIABLES ─────────────────────────────────────────── */
:root {
  --blue:      #00aaff;
  --blue-dark: #0066cc;
  --blue-glow: rgba(0, 170, 255, 0.3);
  --bg:        #050810;
  --bg2:       #0a0f1e;
  --bg3:       #0d1428;
  --text:      #c8d8f0;
  --text-dim:  #5a7090;
  --mono:      "Share Tech Mono", monospace;
  --display:   "Oxanium", sans-serif;
  --r:         10px;
}

/* ── RESET ─────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
a:visited { color: inherit; }
a:focus, a:focus-visible { outline: none; }
html, body { height: 100%; }

/* ── ANIMATIONS ────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 8px var(--blue-glow); }
  50%       { box-shadow: 0 0 20px var(--blue-glow), 0 0 40px rgba(0,170,255,.1); }
}

/* ── ROOT LAYOUT ───────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--display);
  overflow: hidden;
}

#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 1rem 3rem;
  background: rgba(5,8,16,.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0,170,255,.15);
}
#topbar-home {
  font-family: var(--mono);
  font-size: 1.2rem;
  color: var(--blue);
  letter-spacing: 2px;
  text-decoration: none;
  opacity: .9;
  transition: opacity .15s;
}
#topbar-home:hover { opacity: 1; }
.topbar-gt  { color: var(--blue); }
.topbar-cur { color: var(--blue); }
.topbar-sep { color: rgba(0,170,255,.3); font-family: var(--mono); font-size: .85rem; }
#topbar-current {
  font-family: var(--mono);
  font-size: .75rem;
  letter-spacing: .1em;
  color: var(--text-dim);
}

#app {
  display: flex;
  flex-direction: row;
  width: 100vw;
  margin-top: calc(1.2rem + 2rem);
  height: calc(100vh - 1.2rem - 2rem);
  overflow: hidden;
}

/* ── CURSOR GLOW ───────────────────────────────────────── */
.cursor-glow {
  position: fixed;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0,170,255,.06) 0%, transparent 70%);
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  transition: left .08s, top .08s;
}

/* ── SIDEBAR ───────────────────────────────────────────── */
#sidebar {
  width: 76px;
  background: rgba(5,8,16,.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-right: 1px solid rgba(0,170,255,.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0 14px;
  gap: 3px;
  flex-shrink: 0;
  z-index: 200;
  overflow: hidden;
}

.sidebar-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0 14px;
  border-bottom: 1px solid rgba(0,170,255,.15);
  margin-bottom: 6px;
}

.brand-mark { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; }
.brand-diamond {
  width: 10px; height: 10px;
  background: var(--blue);
  box-shadow: 0 0 12px var(--blue);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  animation: pulse 2.5s ease-in-out infinite;
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 62px;
  padding: 11px 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all .15s;
  border-radius: 6px;
  position: relative;
}
.tab-btn:hover  { color: var(--text); background: rgba(0,170,255,.06); }
.tab-btn.active { color: var(--blue); background: rgba(0,170,255,.12); border-color: rgba(0,170,255,.2); }

.tab-icon  { font-size: 1.15rem; line-height: 1; }
.tab-label { font-family: var(--mono); font-size: .55rem; letter-spacing: 1px; text-transform: uppercase; }

.tab-badge {
  position: absolute; top: 5px; right: 5px;
  background: var(--blue); color: #000;
  border-radius: 9px; font-size: .5rem; font-weight: 700;
  padding: 1px 5px; font-family: var(--mono); min-width: 14px;
  text-align: center;
}

/* ── PANELS WRAPPER ────────────────────────────────────── */
#panels {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.panel { display: none; flex: 1; overflow: hidden; }
.panel.active { display: flex; }

/* ── BOARD PANEL ───────────────────────────────────────── */
#panel-board { flex-direction: column; }

/* ── TOOLBAR ───────────────────────────────────────────── */
#toolbar {
  height: 52px;
  background: rgba(5,8,16,.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0,170,255,.15);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  z-index: 100;
  flex-shrink: 0;
}

.toolbar-sep { width: 1px; height: 28px; background: rgba(0,170,255,.15); flex-shrink: 0; }

#inv-name {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-family: var(--display);
  font-size: .85rem; font-weight: 600;
  padding: 4px 8px;
  min-width: 160px;
  transition: border-color .2s, background .2s;
}
#inv-name:hover  { border-color: rgba(0,170,255,.2); }
#inv-name:focus  { outline: none; border-color: var(--blue); background: var(--bg3); }

.toolbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ── BUTTONS ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px;
  border: 1px solid rgba(0,170,255,.35);
  color: var(--blue);
  font-family: var(--mono); font-size: .68rem;
  letter-spacing: 1.5px; text-transform: uppercase;
  transition: all .18s;
  background: transparent; cursor: pointer;
  clip-path: polygon(6px 0%, 100% 0%, calc(100% - 6px) 100%, 0% 100%);
  white-space: nowrap; flex-shrink: 0;
}
.btn:hover        { background: rgba(0,170,255,.1); border-color: var(--blue); box-shadow: 0 0 14px var(--blue-glow); }
.btn.active       { background: rgba(0,170,255,.18); border-color: var(--blue); box-shadow: 0 0 18px var(--blue-glow); color: #fff; }
.btn-primary      { background: rgba(0,170,255,.12); border-color: var(--blue); }
.btn-primary:hover{ background: rgba(0,170,255,.22); }
.btn-danger       { border-color: rgba(255,70,70,.35); color: #ff6666; }
.btn-danger:hover { background: rgba(255,70,70,.1); border-color: #ff6666; box-shadow: 0 0 14px rgba(255,70,70,.25); }
.btn-icon         { padding: 5px 9px; }

/* ── ADD DROPDOWN ──────────────────────────────────────── */
.add-menu-container { position: relative; }
#add-menu {
  position: absolute; top: calc(100% + 6px); left: 0;
  background: var(--bg3);
  border: 1px solid rgba(0,170,255,.2);
  min-width: 210px;
  z-index: 300; display: none;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
#add-menu.open { display: block; animation: fadeUp .12s ease; }

.menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 13px; cursor: pointer;
  font-size: .83rem;
  transition: background .12s;
  border-left: 2px solid transparent;
}
.menu-item:hover { background: rgba(0,170,255,.07); border-left-color: var(--blue); }

.type-badge {
  width: 22px; height: 22px; border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; flex-shrink: 0;
}

/* ── ZOOM ──────────────────────────────────────────────── */
.zoom-controls { display: flex; align-items: center; gap: 3px; }
#zoom-display  { font-family: var(--mono); font-size: .68rem; color: var(--text-dim); min-width: 40px; text-align: center; }

/* ── BOARD CONTAINER ───────────────────────────────────── */
#board-container {
  flex: 1; position: relative; overflow: hidden; cursor: default;
  background-image:
    radial-gradient(ellipse at 50% 40%, rgba(0,170,255,.03) 0%, transparent 55%),
    linear-gradient(rgba(0,170,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,170,255,.035) 1px, transparent 1px);
  background-size: 100% 100%, 48px 48px, 48px 48px;
}
#board-container.panning    { cursor: grabbing; }
#board-container.connecting { cursor: crosshair; }

#world {
  position: absolute; top: 0; left: 0;
  width: 0; height: 0;
  transform-origin: 0 0;
}

/* ── SVG CONNECTIONS ───────────────────────────────────── */
#connections {
  position: absolute; top: 0; left: 0;
  width: 0; height: 0; overflow: visible;
  pointer-events: none;
}
.edge-hit  { stroke: transparent; stroke-width: 14; fill: none; pointer-events: stroke; cursor: pointer; }
.edge-path {
  stroke: rgba(0,170,255,.45); stroke-width: 1.5;
  fill: none; pointer-events: none;
  stroke-linecap: round; stroke-linejoin: round;
  transition: stroke .18s, stroke-width .18s;
}
.edge-path.selected { stroke: var(--blue); stroke-width: 2.5; filter: drop-shadow(0 0 4px rgba(0,170,255,.6)); }
.edge-label-text { fill: var(--text-dim); font-family: var(--mono); font-size: 9px; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.edge-label-bg   { fill: var(--bg3); }

/* ── NODES ─────────────────────────────────────────────── */
.node {
  position: absolute; width: 226px;
  background: var(--bg2);
  border: 1px solid rgba(0,170,255,.13); border-top: none;
  cursor: move; user-select: none;
  transition: box-shadow .18s, border-color .18s;
  box-shadow: 0 4px 18px rgba(0,0,0,.45);
  animation: fadeUp .15s ease;
}
.node:hover    { border-color: rgba(0,170,255,.38); box-shadow: 0 4px 24px rgba(0,0,0,.55), 0 0 14px rgba(0,170,255,.08); }
.node.selected { border-color: rgba(0,170,255,.7); box-shadow: 0 4px 24px rgba(0,0,0,.55), 0 0 22px var(--blue-glow); }
.node.connecting-source { border-color: rgba(68,255,136,.7) !important; box-shadow: 0 0 22px rgba(68,255,136,.25) !important; }

.node-top-bar { height: 3px; }
.node-header {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 9px;
  border-bottom: 1px solid rgba(0,170,255,.08);
  position: relative;
}
.node-icon  { width: 20px; height: 20px; border-radius: 3px; display: flex; align-items: center; justify-content: center; font-size: 10px; flex-shrink: 0; }
.node-title { flex: 1; font-size: .8rem; font-weight: 700; letter-spacing: .3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.node:hover .node-actions { opacity: 1; }

.nBtn { background: transparent; border: none; color: var(--text-dim); cursor: pointer; font-size: 10px; border-radius: 2px; width: 19px; height: 19px; display: flex; align-items: center; justify-content: center; transition: color .12s, background .12s; }
.nBtn:hover           { color: var(--blue);  background: rgba(0,170,255,.12); }
.nBtn.nBtn-link:hover { color: #44ff88;       background: rgba(68,255,136,.1); }
.nBtn.nBtn-del:hover  { color: #ff6666;       background: rgba(255,70,70,.1); }

.node.selected .node-header::after {
  content: 'Suppr';
  font-family: var(--mono); font-size: .54rem;
  color: rgba(255,100,100,.45);
  position: absolute; right: 9px; bottom: -15px;
  background: var(--bg2);
  border: 1px solid rgba(255,100,100,.18);
  padding: 1px 4px; border-radius: 2px;
  pointer-events: none;
}

.node-body { padding: 7px 9px; }
.node-field { display: flex; gap: 5px; margin-bottom: 3px; font-size: .73rem; align-items: flex-start; line-height: 1.35; }
.node-field:last-child { margin-bottom: 0; }
.fl { color: var(--text-dim); font-family: var(--mono); min-width: 42px; flex-shrink: 0; font-size: .64rem; padding-top: 1px; }
.fv { color: var(--text); word-break: break-all; flex: 1; }
.fv a { color: var(--blue); }
.fv a:hover { text-decoration: underline; }
.node-favicon { width: 14px; height: 14px; border-radius: 2px; flex-shrink: 0; margin-top: 1px; }
.node-empty   { color: var(--text-dim); font-style: italic; font-size: .7rem; }
.node-img     { width: 100%; max-height: 180px; object-fit: cover; display: block; margin: -2px 0 4px; }

/* ── CONTEXT MENU ──────────────────────────────────────── */
#ctx-menu { position: fixed; background: var(--bg3); border: 1px solid rgba(0,170,255,.2); z-index: 500; display: none; min-width: 190px; box-shadow: 0 8px 28px rgba(0,0,0,.55); }
#ctx-menu.open { display: block; animation: fadeUp .1s ease; }
.ctx-item { display: flex; align-items: center; gap: 9px; padding: 8px 13px; cursor: pointer; font-size: .8rem; transition: background .12s; border-left: 2px solid transparent; }
.ctx-item:hover  { background: rgba(0,170,255,.07); border-left-color: var(--blue); }
.ctx-item.danger { color: #ff6666; }
.ctx-item.danger:hover { background: rgba(255,70,70,.07); border-left-color: #ff6666; }
.ctx-sep { height: 1px; background: rgba(0,170,255,.08); margin: 3px 0; }
.ctx-sub { font-size: .62rem; font-family: var(--mono); color: var(--text-dim); padding: 6px 13px 3px; letter-spacing: 2px; text-transform: uppercase; }

/* ── MODAL ─────────────────────────────────────────────── */
#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.72); z-index: 1000;
  display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(3px);
}
#modal-overlay.open { display: flex; }
#modal { background: var(--bg3); border: 1px solid rgba(0,170,255,.22); width: 460px; max-width: 96vw; max-height: 88vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.65); animation: fadeUp .15s ease; }
.modal-hdr { display: flex; align-items: center; gap: 11px; padding: 14px 18px; border-bottom: 1px solid rgba(0,170,255,.1); }
.modal-title { flex: 1; font-size: .95rem; font-weight: 700; letter-spacing: .5px; }
#modal-icon  { font-size: 1rem; }
.modal-close { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 16px; padding: 3px; transition: color .12s; }
.modal-close:hover { color: var(--text); }
.modal-body   { padding: 18px; }
.modal-footer { padding: 13px 18px; border-top: 1px solid rgba(0,170,255,.1); display: flex; gap: 8px; justify-content: flex-end; }

/* ── FORM ──────────────────────────────────────────────── */
.fg { margin-bottom: 13px; }
.fg:last-child { margin-bottom: 0; }
.flabel { display: block; font-family: var(--mono); font-size: .64rem; color: var(--text-dim); letter-spacing: 2px; text-transform: uppercase; margin-bottom: 4px; }

.finput, .fselect, .ftextarea {
  width: 100%; background: var(--bg2);
  border: 1px solid rgba(0,170,255,.13);
  color: var(--text); font-family: var(--display); font-size: .83rem;
  padding: 7px 9px; border-radius: 2px;
  transition: border-color .18s, background .18s; outline: none;
}
.finput:focus, .fselect:focus, .ftextarea:focus { border-color: var(--blue); background: var(--bg); }
.fselect   { appearance: none; cursor: pointer; }
.ftextarea { resize: vertical; min-height: 72px; }
.form-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── IMAGE DROP ZONE ───────────────────────────────────── */
.img-drop { border: 1px dashed rgba(0,170,255,.3); padding: 18px; text-align: center; cursor: pointer; font-family: var(--mono); font-size: .7rem; color: var(--text-dim); transition: border-color .18s, background .18s; border-radius: 2px; }
.img-drop:hover, .img-drop.drag-over { border-color: var(--blue); background: rgba(0,170,255,.04); color: var(--blue); }
.img-preview-wrap { margin-top: 8px; display: none; }
.img-preview-wrap img { max-width: 100%; max-height: 160px; object-fit: contain; display: block; margin: 0 auto; }

/* ── EDGE LABEL EDIT ───────────────────────────────────── */
#edge-label-edit { position: fixed; z-index: 800; display: none; align-items: center; gap: 6px; background: var(--bg3); border: 1px solid rgba(0,170,255,.25); padding: 7px 10px; box-shadow: 0 6px 20px rgba(0,0,0,.5); }
#edge-label-edit.open { display: flex; animation: fadeUp .1s ease; }
#edge-label-input { width: 130px; padding: 4px 7px; font-size: .78rem; }
#edge-label-ok    { padding: 4px 9px; font-size: .65rem; }
.edge-label-hint  { font-family: var(--mono); font-size: .64rem; color: var(--text-dim); }

/* ── CONNECT PREVIEW ───────────────────────────────────── */
#preview-svg { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 200; display: none; }

/* ── STATUS BAR ────────────────────────────────────────── */
#status-bar { height: 22px; background: rgba(5,8,16,.92); border-top: 1px solid rgba(0,170,255,.15); display: flex; align-items: center; padding: 0 14px; gap: 20px; font-family: var(--mono); font-size: .64rem; color: var(--text-dim); flex-shrink: 0; }
.si  { display: flex; align-items: center; gap: 5px; }
.sdot { width: 5px; height: 5px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 5px var(--blue); }

/* ── EMPTY HINT ────────────────────────────────────────── */
#empty-hint { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; gap: 8px; }
#empty-hint h2 { font-size: 1.4rem; font-weight: 800; letter-spacing: 6px; color: rgba(0,170,255,.22); }
#empty-hint p  { font-family: var(--mono); font-size: .68rem; color: var(--text-dim); opacity: .45; text-align: center; line-height: 1.9; }

/* ── TOAST ─────────────────────────────────────────────── */
.toast { position: fixed; bottom: 36px; left: 50%; transform: translateX(-50%) translateY(14px); background: var(--bg3); border: 1px solid rgba(0,170,255,.28); padding: 8px 18px; font-family: var(--mono); font-size: .7rem; color: var(--blue); z-index: 9999; opacity: 0; transition: opacity .2s, transform .2s; white-space: nowrap; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── SCROLLBAR ─────────────────────────────────────────── */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: rgba(0,170,255,.18); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,170,255,.35); }


/* ═══════════════════════════════════════════════════════
   MAP PANEL
═══════════════════════════════════════════════════════ */
#panel-map { flex-direction: row; }

#map-leaflet {
  flex: 1;
  min-width: 0;
  z-index: 1;
  background: #0a0f18;
}

#map-panel {
  width: 272px;
  flex-shrink: 0;
  background: rgba(5,8,16,.92);
  border-left: 1px solid rgba(0,170,255,.15);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 10;
}

.mp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 12px 8px;
  border-bottom: 1px solid rgba(0,170,255,.1);
  flex-shrink: 0;
}
.mp-title { font-size: .8rem; font-weight: 700; letter-spacing: 1px; color: var(--text); }

.mp-stats {
  padding: 6px 12px;
  font-family: var(--mono); font-size: .65rem;
  color: var(--text-dim);
  border-bottom: 1px solid rgba(0,170,255,.07);
  flex-shrink: 0;
}

.mp-section {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(0,170,255,.07);
}

.mp-section-title {
  font-family: var(--mono); font-size: .6rem;
  letter-spacing: 2px; text-transform: uppercase;
  color: var(--text-dim); margin-bottom: 7px;
  display: flex; align-items: center; gap: 6px;
}

.mp-count { background: rgba(0,170,255,.15); color: var(--blue); border-radius: 9px; padding: 0 6px; font-size: .55rem; }

.mp-clear-btn {
  margin-left: auto; background: transparent; border: none;
  color: rgba(255,100,100,.4); cursor: pointer; font-size: .75rem;
  transition: color .15s; padding: 0 2px;
}
.mp-clear-btn:hover { color: #ff6666; }

.mp-info-box {
  background: rgba(0,170,255,.05); border: 1px solid rgba(0,170,255,.12);
  padding: 7px 9px; font-size: .74rem; line-height: 1.5;
  border-radius: 2px; color: var(--text);
  word-break: break-word;
}

.mp-tools { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.mp-tools > .btn { width: 100%; justify-content: center; }

.mp-row { display: flex; gap: 5px; align-items: center; }
.mp-row > .btn   { width: auto; flex-shrink: 0; }
.mp-row > .fselect { width: auto; flex-shrink: 0; }

.mp-list-item {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 4px;
  border-radius: 2px;
  transition: background .12s;
  font-size: .72rem;
}
.mp-list-item:hover { background: rgba(0,170,255,.06); }
.mp-list-icon { font-size: .8rem; flex-shrink: 0; }
.mp-list-label { flex: 1; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-list-del { background: transparent; border: none; color: rgba(255,100,100,.3); cursor: pointer; font-size: .75rem; padding: 2px 4px; transition: color .15s; flex-shrink: 0; }
.mp-list-del:hover { color: #ff6666; }

.mp-empty { font-family: var(--mono); font-size: .65rem; color: var(--text-dim); padding: 4px 2px; opacity: .6; }

/* Map panel — buttons sans clip-path biseauté */
#map-panel .btn { clip-path: none; border-radius: 3px; }

/* Leaflet dark theme overrides */
.leaflet-control-zoom a {
  background: var(--bg3) !important;
  color: var(--text) !important;
  border-color: rgba(0,170,255,.2) !important;
  font-family: var(--mono) !important;
}
.leaflet-control-zoom a:hover { background: rgba(0,170,255,.12) !important; color: var(--blue) !important; }
.leaflet-control-attribution { background: rgba(0,0,0,.55) !important; color: rgba(200,216,240,.35) !important; font-size: 9px !important; }
.leaflet-control-attribution a { color: rgba(0,170,255,.6) !important; }
.leaflet-bar { border: 1px solid rgba(0,170,255,.2) !important; box-shadow: none !important; }

/* Leaflet popup custom styles */
.map-popup .leaflet-popup-content-wrapper {
  background: var(--bg3);
  border: 1px solid rgba(0,170,255,.25);
  color: var(--text);
  border-radius: 0;
  box-shadow: 0 8px 28px rgba(0,0,0,.65);
  padding: 0;
}
.map-popup .leaflet-popup-tip { background: var(--bg3); }
.map-popup .leaflet-popup-content { margin: 0; }
.leaflet-popup-close-button { color: var(--text-dim) !important; right: 6px !important; top: 6px !important; }

/* Leaflet tooltip dark */
.leaflet-tooltip {
  background: var(--bg3) !important;
  border: 1px solid rgba(0,170,255,.25) !important;
  color: var(--text) !important;
  font-family: var(--mono) !important;
  font-size: .65rem !important;
  padding: 3px 7px !important;
  border-radius: 0 !important;
  box-shadow: 0 4px 12px rgba(0,0,0,.5) !important;
}
.leaflet-tooltip-bottom::before { border-bottom-color: rgba(0,170,255,.25) !important; }
.leaflet-tooltip-top::before    { border-top-color:    rgba(0,170,255,.25) !important; }

/* ═══════════════════════════════════════════════════════
   NOTES PANEL
═══════════════════════════════════════════════════════ */
#panel-notes { flex-direction: row; }

#notes-list-pane {
  width: 220px;
  flex-shrink: 0;
  background: rgba(5,8,16,.92);
  border-right: 1px solid rgba(0,170,255,.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#notes-editor-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.pane-hdr {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0,170,255,.1);
  flex-shrink: 0;
  background: var(--bg2);
}
.pane-title { font-size: .85rem; font-weight: 700; letter-spacing: .5px; color: var(--text); flex-shrink: 0; }
.pane-add-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid rgba(0,170,255,.3);
  color: var(--blue);
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1.1rem; line-height: 1;
  transition: all .15s; flex-shrink: 0;
}
.pane-add-btn:hover { background: rgba(0,170,255,.1); border-color: var(--blue); box-shadow: 0 0 10px var(--blue-glow); }

#notes-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 6px;
}

.note-item {
  padding: 8px 9px;
  cursor: pointer;
  border-left: 2px solid transparent;
  border-radius: 2px;
  margin-bottom: 2px;
  transition: all .12s;
}
.note-item:hover  { background: rgba(0,170,255,.06); }
.note-item.active { background: rgba(0,170,255,.1); border-left-color: var(--blue); }
.note-item-title   { font-size: .78rem; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-item-preview { font-size: .65rem; color: var(--text-dim); margin-top: 2px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#notes-empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: .72rem;
  opacity: .5;
}

#notes-active {
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  /* display controlled by JS */
}

.note-textarea {
  flex: 1;
  resize: none;
  background: var(--bg);
  border: none;
  border-top: 1px solid rgba(0,170,255,.07);
  color: var(--text);
  font-family: var(--mono);
  font-size: .82rem;
  line-height: 1.75;
  padding: 18px 22px;
  outline: none;
  min-height: 0;
}

.note-preview {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
  line-height: 1.7;
  font-size: .84rem;
  min-height: 0;
}
.note-preview h1 { font-size: 1.3rem; color: var(--blue); margin: 16px 0 8px; }
.note-preview h2 { font-size: 1.1rem; color: var(--blue); margin: 14px 0 6px; border-bottom: 1px solid rgba(0,170,255,.15); padding-bottom: 4px; }
.note-preview h3 { font-size: .95rem; color: var(--blue); margin: 12px 0 5px; }
.note-preview p  { margin-bottom: 10px; }
.note-preview code { background: var(--bg3); padding: 2px 6px; font-family: var(--mono); font-size: .8em; border: 1px solid rgba(0,170,255,.1); }
.note-preview pre  { background: var(--bg3); padding: 14px 16px; overflow-x: auto; margin: 10px 0; border: 1px solid rgba(0,170,255,.1); }
.note-preview pre code { background: transparent; border: none; padding: 0; }
.note-preview a    { color: var(--blue); }
.note-preview a:hover { text-decoration: underline; }
.note-preview ul, .note-preview ol { margin-left: 22px; margin-bottom: 10px; }
.note-preview li { margin-bottom: 3px; }
.note-preview blockquote { border-left: 3px solid rgba(0,170,255,.4); padding-left: 14px; margin: 10px 0; opacity: .75; }
.note-preview strong { color: var(--text); font-weight: 700; }
.note-preview em { color: rgba(200,216,240,.7); font-style: italic; }
.note-preview hr { border: none; border-top: 1px solid rgba(0,170,255,.15); margin: 14px 0; }
.note-preview table { border-collapse: collapse; width: 100%; margin-bottom: 10px; font-size: .82rem; }
.note-preview th, .note-preview td { border: 1px solid rgba(0,170,255,.15); padding: 5px 9px; text-align: left; }
.note-preview th { background: rgba(0,170,255,.07); color: var(--blue); }

/* ═══════════════════════════════════════════════════════
   TODO PANEL
═══════════════════════════════════════════════════════ */
#panel-todo { flex-direction: column; }

#todo-hdr {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px 12px;
  background: rgba(5,8,16,.92);
  border-bottom: 1px solid rgba(0,170,255,.15);
  flex-shrink: 0;
}

.todo-progress {
  font-family: var(--mono);
  font-size: .68rem;
  color: var(--text-dim);
  background: var(--bg3);
  padding: 2px 9px;
  border-radius: 9px;
  border: 1px solid rgba(0,170,255,.1);
}

#todo-add-row {
  display: flex;
  gap: 8px;
  padding: 12px 24px;
  border-bottom: 1px solid rgba(0,170,255,.07);
  flex-shrink: 0;
}

#todo-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 24px 24px;
  max-width: 680px;
  width: 100%;
  align-self: flex-start;
}

.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid rgba(0,170,255,.06);
  animation: fadeUp .12s ease;
}
.todo-item:last-child { border-bottom: none; }

.todo-item input[type="checkbox"] {
  width: 16px; height: 16px;
  flex-shrink: 0; cursor: pointer;
  accent-color: var(--blue);
  margin-top: 2px;
}

.todo-text {
  flex: 1;
  font-size: .88rem;
  line-height: 1.45;
  word-break: break-word;
  transition: opacity .2s, text-decoration .2s;
}

.todo-item.done .todo-text {
  text-decoration: line-through;
  opacity: .35;
}

.todo-del {
  background: transparent; border: none;
  cursor: pointer; font-size: .8rem;
  opacity: .25; transition: opacity .15s;
  flex-shrink: 0; padding: 2px 4px;
  margin-top: 1px;
  color: var(--text);
}
.todo-del:hover { opacity: .8; }

/* Code / Texte node */
.node-code {
  font-family: 'Share Tech Mono', monospace;
  font-size: .6rem;
  line-height: 1.5;
  color: var(--text);
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(167,139,250,.15);
  border-radius: 4px;
  padding: 5px 7px;
  margin: 2px 0 0;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 110px;
  overflow: hidden;
}
.node-code-ta {
  font-family: 'Share Tech Mono', monospace;
  font-size: .75rem;
  resize: vertical;
}

/* Password dialog */
#pwd-dialog {
  position: fixed;
  z-index: 4000;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 290px;
  background: var(--bg2);
  border: 1px solid rgba(0,170,255,.28);
  border-radius: 8px;
  padding: 18px 16px 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.7);
}
.pwd-title {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 6px;
}
.pwd-hint {
  font-size: .62rem;
  color: var(--text-dim);
  margin-bottom: 8px;
  line-height: 1.4;
}
.pwd-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

/* Lock animation overlay */
#lock-anim-overlay {
  position: fixed; inset: 0; z-index: 9000;
  display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
#lock-anim-overlay.active { display: flex; }
.lock-anim-box { display:flex; flex-direction:column; align-items:center; gap:20px; overflow:visible; }
#lock-svg { overflow: visible; }
.lock-body  { fill:var(--bg3); stroke:var(--blue); stroke-width:2.5; }
.lock-hole  { fill:rgba(0,0,0,.45); }
.lock-shackle { fill:none; stroke:var(--blue); stroke-width:7; stroke-linecap:round; stroke-linejoin:round; }
.lock-anim-label {
  font-family:'Share Tech Mono',monospace; font-size:.72rem;
  color:var(--text-dim); letter-spacing:.08em;
}

/* Shackle movement */
#lock-anim-overlay.locking   #lock-shackle-g { animation: shackle-close 3.5s cubic-bezier(.34,1.15,.64,1) forwards; }
#lock-anim-overlay.unlocking #lock-shackle-g { animation: shackle-open  3.5s cubic-bezier(.34,1.15,.64,1) forwards; }

@keyframes shackle-close {
  0%,12%  { transform: translateY(-17px); }
  62%     { transform: translateY(3px); }
  78%     { transform: translateY(-1px); }
  100%    { transform: translateY(0); }
}
@keyframes shackle-open {
  0%,12%  { transform: translateY(0); }
  62%     { transform: translateY(-19px); }
  78%     { transform: translateY(-15px); }
  100%    { transform: translateY(-17px); }
}

/* Glow + stroke colour on completion */
#lock-anim-overlay.locking   #lock-svg  { animation: glow-green 3.5s forwards; }
#lock-anim-overlay.unlocking #lock-svg  { animation: glow-blue  3.5s forwards; }

#lock-anim-overlay.locking   .lock-body,
#lock-anim-overlay.locking   .lock-shackle { animation: stroke-green 3.5s forwards; }
#lock-anim-overlay.unlocking .lock-body,
#lock-anim-overlay.unlocking .lock-shackle { animation: stroke-blue  3.5s forwards; }

@keyframes glow-green {
  0%,58%  { filter: none; }
  82%     { filter: drop-shadow(0 0 20px rgba(52,211,153,.9)) drop-shadow(0 0 8px rgba(52,211,153,.5)); }
  100%    { filter: drop-shadow(0 0 13px rgba(52,211,153,.65)); }
}
@keyframes glow-blue {
  0%,58%  { filter: none; }
  82%     { filter: drop-shadow(0 0 20px rgba(0,170,255,.9)) drop-shadow(0 0 8px rgba(0,170,255,.5)); }
  100%    { filter: drop-shadow(0 0 13px rgba(0,170,255,.65)); }
}
@keyframes stroke-green {
  0%,58%  { stroke: var(--blue); }
  100%    { stroke: #34d399; }
}
@keyframes stroke-blue {
  0%,58%  { stroke: var(--blue); }
  100%    { stroke: #38bdf8; }
}
