/* Palette from poza.in: #0b080c ink-black, #eae5ec soft white, #c2a4ff lavender, #a87cff violet. Font: Geist. */
:root, [data-theme="dark"] {
  --bg: #0b080c; --panel: #120e14; --node: #171219; --raise: #1d1720;
  --ink: #eae5ec; --muted: #9a90a1; --line: #2a2230;
  --accent: #c2a4ff; --accent2: #a87cff; --accent-ink: #0b080c;
  --accent-soft: rgba(194, 164, 255, .12); --hit: rgba(240, 210, 122, .35);
  --danger: #ff8f8f; --shadow: 0 12px 40px rgba(0, 0, 0, .5);
  --dot: rgba(234, 229, 236, .07);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f7f4f9; --panel: #ffffff; --node: #ffffff; --raise: #f1ecf4;
  --ink: #1a1420; --muted: #6c6274; --line: #e4dce9;
  --accent: #7a4ad8; --accent2: #a87cff; --accent-ink: #ffffff;
  --accent-soft: rgba(122, 74, 216, .1); --hit: rgba(240, 190, 40, .35);
  --danger: #c94242; --shadow: 0 12px 40px rgba(60, 30, 90, .14);
  --dot: rgba(26, 20, 32, .08);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.4 Geist, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; display: flex; flex-direction: column; overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
kbd {
  font: 500 11px "Geist Mono", ui-monospace, Menlo, monospace; padding: 1px 6px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--raise); color: var(--muted); white-space: nowrap;
}
svg { stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* the soft violet light that follows the pointer, as on poza.in */
.glow {
  position: fixed; left: var(--gx, 50%); top: var(--gy, 40%); width: 420px; height: 260px; z-index: 0;
  border-radius: 50%; background: var(--accent2); filter: blur(90px); opacity: .13;
  transform: translate(-50%, -50%); pointer-events: none; transition: opacity .6s;
}
[data-theme="light"] .glow { opacity: .1; }
@media (prefers-reduced-motion: reduce) { .glow { display: none; } }

/* ---------- top bar ---------- */
.bar {
  position: relative; z-index: 3; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 82%, transparent);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: -.01em; margin-right: 4px; white-space: nowrap; }
.mark { width: 22px; height: 22px; color: var(--accent); }
.mark circle { fill: currentColor; stroke: none; }
.mark path { stroke-width: 1.6; }
.map-title {
  min-width: 80px; width: 22ch; max-width: 32vw; padding: 6px 10px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; font-weight: 550;
}
.map-title:hover { border-color: var(--line); }
.map-title:focus { border-color: var(--accent); outline: none; background: var(--raise); }
.saved { font-size: 12px; color: var(--muted); white-space: nowrap; }
.spacer { flex: 1; }
.group { display: flex; gap: 2px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 100px; cursor: pointer;
  border: 1px solid var(--line); background: var(--raise); font-size: 13px; font-weight: 550; white-space: nowrap;
  transition: border-color .15s, background .15s, transform .1s;
}
.pill:hover { border-color: var(--accent); }
.pill:active { transform: scale(.97); }
.pill.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pill.primary:hover { background: var(--accent2); border-color: var(--accent2); }
.pill.small { padding: 5px 11px; font-size: 12.5px; }
.pill.danger { color: var(--danger); }
.pill.danger.armed { background: var(--danger); border-color: var(--danger); color: var(--bg); }
.pill kbd { font-size: 10px; padding: 0 4px; }
.icon {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 100px; cursor: pointer;
  border: 1px solid transparent; background: transparent; font-size: 18px; line-height: 1;
}
.icon:hover { background: var(--raise); border-color: var(--line); }
.icon:disabled { opacity: .35; cursor: default; background: transparent; border-color: transparent; }
.icon svg { width: 18px; height: 18px; }
.icon.small { width: 28px; height: 28px; font-size: 18px; }
.search { position: relative; width: 210px; }
.search input {
  width: 100%; padding: 7px 60px 7px 14px; border-radius: 100px; border: 1px solid var(--line); background: var(--raise);
}
.search input:focus { border-color: var(--accent); outline: none; }
.search .count { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.menu {
  position: fixed; z-index: 20; min-width: 230px; padding: 6px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.menu button {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 9px; background: none; text-align: left; cursor: pointer;
}
.menu button:hover, .menu button:focus-visible { background: var(--accent-soft); outline: none; }
.menu small { color: var(--muted); font-size: 11.5px; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }

.crumbs {
  position: relative; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 7px 16px; font-size: 13px;
  background: var(--accent-soft); border-bottom: 1px solid var(--line);
}
.crumbs span { color: var(--muted); }

/* ---------- canvas ---------- */
main { position: relative; z-index: 1; flex: 1; display: flex; min-height: 0; }
#viewport {
  flex: 1; position: relative; overflow: hidden; cursor: grab; touch-action: none; min-width: 0; outline: none;
  background-image: radial-gradient(var(--dot) 1px, transparent 1px); background-size: 22px 22px;
}
#viewport.panning { cursor: grabbing; }
#stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#links { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
#links path { fill: none; stroke-linecap: round; opacity: .85; }

.node {
  --c: var(--accent);
  position: absolute; display: flex; align-items: center; gap: 7px; width: max-content; max-width: 300px;
  padding: 7px 12px; border-radius: 11px; cursor: pointer; user-select: none; -webkit-user-select: none;
  background: var(--node); border: 1.5px solid color-mix(in srgb, var(--c) 45%, var(--node));
  font-size: 14px; font-weight: 450; line-height: 19px;
  transition: box-shadow .15s, border-color .15s, opacity .15s;
}
.node.side-l { flex-direction: row-reverse; }
.node.d1 {
  padding: 9px 14px; border-radius: 14px; font-size: 15px; font-weight: 600; line-height: 20px;
  background: color-mix(in srgb, var(--c) 20%, var(--node)); border-color: color-mix(in srgb, var(--c) 70%, var(--node));
}
.node.root {
  padding: 12px 22px; border-radius: 100px; font-size: 18px; font-weight: 650; line-height: 24px;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: var(--accent); color: var(--accent-ink);
  box-shadow: 0 0 40px color-mix(in srgb, var(--accent2) 35%, transparent);
}
.node .label { max-width: 240px; white-space: pre-wrap; overflow-wrap: anywhere; outline: none; min-width: 1ch; }
.node .label:empty::before { content: 'Type an idea'; color: var(--muted); }
.node .label[contenteditable="true"] { cursor: text; user-select: text; -webkit-user-select: text; }
.node:hover { border-color: var(--c); }
.node.selected { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 30%, transparent), 0 6px 24px rgba(0, 0, 0, .25); }
.node.root.selected { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 40%, transparent), 0 0 40px color-mix(in srgb, var(--accent2) 40%, transparent); }
.node.hit { box-shadow: 0 0 0 3px var(--hit); }
.node.done .label { text-decoration: line-through; color: var(--muted); }
.node .tick {
  flex: none; display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%;
  background: var(--c); color: var(--node);
}
.node .tick svg { width: 11px; height: 11px; stroke-width: 3; }
.node .note-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--c); opacity: .9; }
.node .progress { flex: none; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.node.root .progress { color: inherit; opacity: .75; }
.node .fold {
  flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; border: 0; cursor: pointer;
  font-size: 11px; font-weight: 600; line-height: 20px; font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--c) 22%, transparent); color: var(--ink);
}
.node .fold:hover { background: color-mix(in srgb, var(--c) 40%, transparent); }
.node.dragging { opacity: .35; }
.node.drop-child { box-shadow: 0 0 0 3px var(--c), 0 0 24px color-mix(in srgb, var(--c) 50%, transparent); }
.node.drop-before::after, .node.drop-after::after {
  content: ""; position: absolute; left: 6px; right: 6px; height: 3px; border-radius: 3px; background: var(--c);
}
.node.drop-before::after { top: -8px; }
.node.drop-after::after { bottom: -8px; }
.ghost {
  position: fixed; z-index: 30; pointer-events: none; padding: 7px 12px; border-radius: 11px; max-width: 240px;
  background: var(--panel); border: 1.5px solid var(--accent); box-shadow: var(--shadow); font-size: 14px;
  transform: translate(10px, 10px) rotate(-2deg);
}
.zoom {
  position: absolute; display: flex; align-items: center; gap: 4px; padding: 4px; border-radius: 100px;
  right: calc(14px + env(safe-area-inset-right)); bottom: calc(14px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--panel) 85%, transparent); border: 1px solid var(--line); backdrop-filter: blur(10px);
}
.stats {
  position: absolute; left: calc(14px + env(safe-area-inset-left)); bottom: calc(18px + env(safe-area-inset-bottom));
  font-size: 12px; color: var(--muted); pointer-events: none; font-variant-numeric: tabular-nums;
}

/* ---------- side panel ---------- */
aside {
  width: 300px; flex: none; display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; overflow: auto;
  background: color-mix(in srgb, var(--panel) 88%, transparent); border-left: 1px solid var(--line); backdrop-filter: blur(14px);
}
body.no-panel aside { display: none; }
.panel-head { display: flex; align-items: flex-start; gap: 8px; }
.path { flex: 1; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; padding-top: 5px; }
aside label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .07em; margin-top: 4px; }
aside label.check { text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--ink); font-weight: 450; }
aside textarea {
  width: 100%; border-radius: 12px; border: 1px solid var(--line); background: var(--raise); padding: 9px 11px; resize: vertical;
}
aside textarea:focus { border-color: var(--accent); outline: none; }
#nodeText { font-weight: 550; min-height: 44px; }
#notes { flex: 1; min-height: 140px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches button {
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; background: var(--sw);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15);
}
.swatches button.auto { background: conic-gradient(#c2a4ff, #ffb38a, #7ee0c0, #8ec5ff, #c2a4ff); }
.swatches button.on { border-color: var(--ink); }
.swatches button:disabled { opacity: .3; cursor: default; }
label.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
label.check input { accent-color: var(--accent); width: 16px; height: 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.info { font-size: 12px; color: var(--muted); }
.details-btn { position: fixed; z-index: 4; right: 14px; top: 70px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 40; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; padding: 9px 10px 9px 16px; border-radius: 100px;
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow); font-size: 13px; max-width: calc(100vw - 32px);
}
.toast button { border: 0; background: var(--accent); color: var(--accent-ink); border-radius: 100px; padding: 4px 12px; font-weight: 600; cursor: pointer; }

/* ---------- dialogs ---------- */
dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); padding: 18px 20px 20px; border-radius: 20px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(5, 3, 6, .55); backdrop-filter: blur(3px); }
dialog h2 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
dialog h3 { margin: 16px 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
dialog p { color: var(--muted); margin: 10px 0; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sheet { width: min(640px, calc(100vw - 24px)); }
.templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.templates button, .formats button {
  display: flex; flex-direction: column; gap: 2px; align-items: flex-start; text-align: left; padding: 11px 12px;
  border-radius: 14px; border: 1px solid var(--line); background: var(--raise); cursor: pointer;
}
.templates button:hover, .formats button:hover { border-color: var(--accent); background: var(--accent-soft); }
.templates b, .formats b { font-weight: 600; }
.templates span, .formats span { font-size: 12px; color: var(--muted); }
.maplist { display: flex; flex-direction: column; gap: 4px; }
.maprow {
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; border-radius: 12px; border: 1px solid transparent;
}
.maprow:hover { background: var(--raise); }
.maprow.current { border-color: var(--accent); background: var(--accent-soft); }
.maprow .open { flex: 1; min-width: 0; text-align: left; border: 0; background: none; cursor: pointer; padding: 0; }
.maprow .open b { display: block; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.maprow .open span { font-size: 12px; color: var(--muted); }
.formats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 14px; }
.opts { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; font-size: 13px; }
.fine { font-size: 12px; }
.copyrow { display: flex; gap: 8px; }
.copyrow input { flex: 1; min-width: 0; padding: 7px 12px; border-radius: 100px; border: 1px solid var(--line); background: var(--raise); font-size: 12.5px; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
#pasteText {
  width: 100%; border-radius: 12px; border: 1px solid var(--line); background: var(--raise); padding: 10px 12px;
  font: 13px/1.5 "Geist Mono", ui-monospace, Menlo, monospace; resize: vertical;
}
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin-top: 14px; font-size: 13px; }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .brand span, .saved { display: none; }
  .search { width: 150px; }
}
@media (max-width: 680px) {
  .bar { gap: 6px; }
  .map-title { width: 14ch; max-width: 40vw; }
  .search { order: 10; width: 100%; }
  #shareBtn { display: none; }
  main { flex-direction: column; }
  aside {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; width: auto; max-height: 55vh;
    border-left: 0; border-top: 1px solid var(--line); border-radius: 20px 20px 0 0; box-shadow: var(--shadow);
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
  #notes { min-height: 90px; }
  .keys { grid-template-columns: 1fr; }
  .details-btn { top: auto; bottom: calc(66px + env(safe-area-inset-bottom)); }
}
