/* ── Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Crimson+Pro:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,300..700;1,9..40,300..700&display=swap');

/* ── Design Tokens ── */
:root {
  --bg: #eef3fb;
  --bg-warm: #f8f5f0;
  --ink: #182235;
  --ink-soft: #26354d;
  --muted: #66758c;
  --muted-soft: #8a9bb5;
  --line: #dbe5f2;
  --line-strong: #c4d2e6;

  --panel: rgba(255, 255, 255, 0.78);
  --panel-strong: rgba(255, 255, 255, 0.94);
  --glass-blur: blur(20px) saturate(1.1);

  --shadow-sm: 0 2px 8px rgba(31, 47, 74, 0.06);
  --shadow-md: 0 8px 28px rgba(31, 47, 74, 0.10);
  --shadow-lg: 0 18px 48px rgba(31, 47, 74, 0.15);
  --shadow-xl: 0 28px 64px rgba(15, 23, 42, 0.22);
  --shadow-glow: 0 0 40px rgba(52, 120, 216, 0.18);

  --blue:    #3478d8;
  --green:   #19a974;
  --red:     #e05d5d;
  --gold:    #e0a420;
  --violet:  #7a62d3;
  --cyan:    #1aa7b8;
  --pink:    #d85f9c;

  --blue-glow:   rgba(52, 120, 216, 0.22);
  --green-glow:  rgba(25, 169, 116, 0.22);
  --red-glow:    rgba(224, 93, 93, 0.22);
  --gold-glow:   rgba(224, 164, 32, 0.22);
  --violet-glow: rgba(122, 98, 211, 0.22);
  --cyan-glow:   rgba(26, 167, 184, 0.22);
  --pink-glow:   rgba(216, 95, 156, 0.22);

  --font-ui:    'DM Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-title: 'Crimson Pro', 'Georgia', 'Times New Roman', serif;

  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 28px;
  --s-8: 40px;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-full: 999px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  width: 100%; height: 100%; margin: 0; overflow: hidden;
}

body {
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: 400;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select { font: inherit; }

/* ── App Shell ── */
.app {
  position: relative;
  width: 100vw; height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 8% 6%, rgba(52, 120, 216, 0.09), transparent 32rem),
    radial-gradient(ellipse at 92% 92%, rgba(25, 169, 116, 0.07), transparent 30rem),
    radial-gradient(ellipse at 50% 50%, rgba(122, 98, 211, 0.04), transparent 40rem),
    #f7faff;
}

/* ── Splash Screen ── */
.splash {
  position: absolute; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(52, 120, 216, 0.06), transparent 50rem), #f8faff;
  transition: opacity 500ms ease, visibility 500ms ease;
}
.splash.is-fading { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-inner { display: grid; gap: var(--s-6); justify-items: center; text-align: center; }
.splash-emblem {
  width: 72px; height: 72px;
  display: grid; place-items: center;
  border-radius: 22px;
  background: linear-gradient(135deg, #223753 0%, #1a2d45 100%);
  box-shadow: 0 16px 40px rgba(31, 47, 74, 0.28), 0 0 0 1px rgba(255,255,255,0.12) inset;
  animation: splashPulse 3.2s ease-in-out infinite;
}
.splash-emblem svg { width: 36px; height: 36px; color: #fff; }
@keyframes splashPulse {
  0%, 100% { box-shadow: 0 16px 40px rgba(31, 47, 74, 0.28), 0 0 0 1px rgba(255,255,255,0.12) inset; }
  50%      { box-shadow: 0 20px 52px rgba(31, 47, 74, 0.36), 0 0 0 1px rgba(255,255,255,0.20) inset; }
}
.splash-title { margin: 0; font-family: var(--font-title); font-size: 26px; font-weight: 600; color: #1a2d45; letter-spacing: -0.3px; line-height: 1.08; }
.splash-sub { margin: 0; color: var(--muted); font-size: 14px; font-weight: 450; line-height: 1.4; }
.splash-bar { width: 180px; height: 4px; overflow: hidden; border-radius: var(--r-full); background: #e4ecf8; }
.splash-bar-fill {
  width: 0%; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, #3478d8, #19a974, #7a62d3); background-size: 200% 100%;
  animation: splashBar 2.6s cubic-bezier(.4,0,.2,1) forwards;
}
@keyframes splashBar {
  0%   { width: 0%; background-position: 0% 50%; }
  60%  { width: 68%; background-position: 60% 50%; }
  100% { width: 100%; background-position: 100% 50%; }
}

/* ── SVG Canvas ── */
.map-svg {
  display: block; width: 100%; height: 100%;
  cursor: grab; touch-action: none;
  background:
    linear-gradient(rgba(52, 120, 216, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(52, 120, 216, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
}
.map-svg.is-dragging { cursor: grabbing; }
.world { transform-origin: 0 0; will-change: transform; }

/* ── Links ── */
.map-link {
  fill: none; stroke: var(--branch-color); stroke-width: 3.5;
  stroke-linecap: round; opacity: 0.58;
  transition: opacity 220ms ease, stroke-width 220ms ease;
}
.map-link.dimmed { opacity: 0.10; }
.map-link.highlighted { opacity: 0.92; stroke-width: 5; filter: drop-shadow(0 0 6px var(--branch-color)); }

/* ── Nodes ── */
.node { cursor: pointer; outline: none; transition: filter 220ms ease; }
.node-rect {
  fill: #fff; stroke: var(--branch-color); stroke-width: 2;
  filter: url(#nodeShadow);
  transition: opacity 220ms ease, stroke-width 220ms ease, fill 220ms ease, filter 280ms ease;
}
.node-root .node-rect  { fill: #1f304a; stroke: #1f304a; }
.node-branch .node-rect { fill: var(--branch-color); }
.node-leaf .node-rect   { fill: #fff; }
.node-image .node-rect  { fill: #fff; stroke-dasharray: 7 5; }
.node-image-thumb { pointer-events: none; }

.node-text {
  fill: #24324a; font-size: 13px; font-weight: 600;
  text-anchor: middle; dominant-baseline: middle; pointer-events: none; letter-spacing: -0.1px;
}
.node-root .node-text, .node-branch .node-text { fill: #fff; }

.node-meta { fill: #7890aa; font-size: 10px; font-weight: 700; text-anchor: middle; pointer-events: none; letter-spacing: 0.3px; }
.node-badge { fill: rgba(255,255,255,0.88); stroke: rgba(190,205,224,0.85); stroke-width: 1; }

.node.dimmed .node-rect, .node.dimmed .node-text, .node.dimmed .node-meta { opacity: 0.18; }
.node.highlighted .node-rect, .node.selected .node-rect { stroke-width: 4; }
.node.selected .node-rect { fill: #111e31; stroke: #111e31; }
.node.selected .node-text { fill: #fff; }
.node:hover .node-rect { filter: url(#nodeShadow) drop-shadow(0 0 14px var(--branch-glow, rgba(52,120,216,0.30))); }
.node:hover { filter: brightness(1.04); }

@keyframes nodeAppear {
  0%   { opacity: 0; transform: translateY(12px) scale(0.92); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.node.is-entering { animation: nodeAppear 420ms cubic-bezier(.22,.61,.36,1) backwards; }

/* ── ⌘ Trigger Button ── */
.cmd-trigger {
  position: absolute; left: 20px; bottom: 24px; z-index: 20;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 1px solid rgba(190, 205, 224, 0.50);
  border-radius: var(--r-md);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.60);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  cursor: pointer;
  transition: all 260ms cubic-bezier(.22,.61,.36,1);
}
.cmd-trigger:hover {
  color: var(--blue);
  border-color: rgba(52, 120, 216, 0.35);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-md), 0 0 0 4px rgba(52, 120, 216, 0.08);
  transform: translateY(-2px);
}
.cmd-trigger:active { transform: translateY(0); }
.cmd-trigger::after {
  content: "Spazio";
  position: absolute; left: 50%; bottom: -18px;
  transform: translateX(-50%);
  font-size: 9px; font-weight: 750; letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--muted-soft); opacity: 0; white-space: nowrap;
  transition: opacity 260ms ease;
}
.cmd-trigger:hover::after { opacity: 1; }

/* ── Command Palette Overlay ── */
.cmd-overlay {
  position: absolute; inset: 0; z-index: 50;
  background: rgba(15, 23, 42, 0.32);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: grid; place-items: center;
  animation: overlayIn 180ms ease;
}
.cmd-overlay.hidden, .breadcrumb.hidden { display: none; }
@keyframes overlayIn { 0% { opacity: 0; backdrop-filter: blur(0); } 100% { opacity: 1; backdrop-filter: blur(6px); } }

.cmd-palette {
  width: min(540px, calc(100vw - 32px));
  max-height: min(620px, calc(100vh - 64px));
  display: grid; gap: 10px;
  padding: var(--s-4);
  border: 1px solid rgba(190, 205, 224, 0.65);
  border-radius: var(--r-xl);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255,255,255,0.5) inset;
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  animation: paletteIn 220ms cubic-bezier(.22,.61,.36,1);
  overflow-y: auto;
}
@keyframes paletteIn { 0% { opacity: 0; transform: scale(0.95) translateY(-12px); } 100% { opacity: 1; transform: scale(1) translateY(0); } }

/* Search */
.cmd-search-wrap {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 2px var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(247, 250, 255, 0.7);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.cmd-search-wrap:focus-within {
  border-color: rgba(52, 120, 216, 0.40);
  box-shadow: 0 0 0 3px rgba(52, 120, 216, 0.06);
}
.cmd-search-icon { flex-shrink: 0; color: var(--muted); }
.cmd-search {
  flex: 1; width: 100%;
  border: 0; padding: 10px 0;
  color: var(--ink); background: transparent;
  font-size: 15px; font-weight: 500;
  outline: none;
}
.cmd-search::placeholder { color: var(--muted-soft); font-weight: 440; }
.cmd-kbd-inline {
  flex-shrink: 0;
  padding: 2px 7px; border: 1px solid var(--line); border-radius: 5px;
  color: var(--muted); background: #f5f7fb;
  font-size: 10px; font-weight: 700; letter-spacing: 0.4px;
}

/* Results */
.cmd-results {
  max-height: 220px; overflow-y: auto;
  border-radius: var(--r-md);
  border: 1px solid #edf2f8;
}
.cmd-results.hidden { display: none; }
.cmd-result {
  display: block; width: 100%;
  border: 0; border-bottom: 1px solid #f1f5fa;
  border-radius: 0; padding: var(--s-2) var(--s-3);
  text-align: left; color: var(--ink); background: transparent; cursor: pointer;
  transition: background 120ms ease;
}
.cmd-result:first-child { border-radius: var(--r-md) var(--r-md) 0 0; }
.cmd-result:last-child  { border-radius: 0 0 var(--r-md) var(--r-md); border-bottom: 0; }
.cmd-result:hover, .cmd-result:focus-visible { background: #f6f9fe; }
.cmd-result strong { display: block; font-size: 13px; margin-bottom: 2px; font-weight: 650; }
.cmd-result span   { display: block; color: var(--muted); font-size: 11px; line-height: 1.3; }
.cmd-result-empty   { padding: var(--s-4); text-align: center; color: var(--muted); font-size: 13px; }

/* Section labels */
.cmd-section-label {
  color: var(--muted); font-size: 10px; font-weight: 750;
  text-transform: uppercase; letter-spacing: 0.6px;
}

/* Chapter chips */
.cmd-chapters {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.cmd-chapter-chip {
  flex: 0 0 auto;
  padding: 6px var(--s-3);
  border: 1px solid var(--line); border-radius: var(--r-full);
  color: var(--ink-soft); background: rgba(255,255,255,0.7);
  font-size: 12px; font-weight: 550; cursor: pointer;
  white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis;
  transition: all 180ms ease;
}
.cmd-chapter-chip:hover {
  border-color: rgba(52, 120, 216, 0.38);
  background: #eef6ff;
}
.cmd-chapter-chip.is-active {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
  box-shadow: 0 4px 12px rgba(52, 120, 216, 0.28);
  font-weight: 650;
}

/* Action grid */
.cmd-actions {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px;
}
.cmd-action {
  display: flex; align-items: center; gap: 7px;
  padding: 9px var(--s-3);
  border: 1px solid var(--line); border-radius: var(--r-md);
  color: var(--ink-soft); background: rgba(255,255,255,0.7);
  font-size: 12px; font-weight: 550; cursor: pointer;
  transition: all 160ms ease;
}
.cmd-action:hover {
  border-color: rgba(52, 120, 216, 0.38);
  background: #eef6ff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(52, 120, 216, 0.08);
}
.cmd-action:active { transform: translateY(0); }
.cmd-action-icon { flex-shrink: 0; width: 16px; height: 16px; color: var(--muted); display: grid; place-items: center; }
.cmd-action-label { flex: 1; min-width: 0; text-align: left; }
.cmd-action kbd {
  flex-shrink: 0; padding: 1px 5px; border-radius: 4px;
  background: #f1f5fa; color: var(--muted-soft);
  font-size: 10px; font-weight: 700; letter-spacing: 0.3px;
}

/* Depth row */
.cmd-depth-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.cmd-depth-group { display: flex; gap: var(--s-1); }
.cmd-depth-btn {
  width: 34px; height: 30px; border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--ink-soft); background: rgba(255,255,255,0.7);
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 160ms ease;
}
.cmd-depth-btn:hover { border-color: rgba(52, 120, 216, 0.35); background: #eef6ff; }
.cmd-depth-btn.is-active {
  border-color: var(--blue); color: #fff; background: var(--blue);
  box-shadow: 0 2px 8px rgba(52, 120, 216, 0.28);
}

/* Density buttons */
.cmd-density-btn {
  padding: 5px 10px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--ink-soft); background: rgba(255,255,255,0.7);
  font-size: 11px; font-weight: 600; cursor: pointer;
  transition: all 160ms ease;
  white-space: nowrap;
}
.cmd-density-btn:hover { border-color: rgba(52, 120, 216, 0.35); background: #eef6ff; }
.cmd-density-btn.is-active {
  border-color: var(--blue); color: #fff; background: var(--blue);
  box-shadow: 0 2px 8px rgba(52, 120, 216, 0.28);
}

/* Chapter nav arrows */
.cmd-chapter-nav {
  display: flex; gap: 8px;
}
.cmd-chapter-arrow {
  flex: 1; padding: 8px var(--s-3);
  border: 1px solid var(--line); border-radius: var(--r-md);
  color: var(--ink-soft); background: rgba(255,255,255,0.7);
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 160ms ease;
}
.cmd-chapter-arrow:hover {
  border-color: rgba(52, 120, 216, 0.35); background: #eef6ff;
  transform: translateY(-1px); box-shadow: 0 4px 12px rgba(52, 120, 216, 0.06);
}

/* Focus states for palette */
.cmd-action:focus-visible, .cmd-chapter-chip:focus-visible, .cmd-depth-btn:focus-visible,
.cmd-chapter-arrow:focus-visible, .cmd-result:focus-visible, .cmd-trigger:focus-visible {
  outline: 3px solid rgba(52, 120, 216, 0.28); outline-offset: 2px;
}
.node:focus-visible {
  outline: 3px solid rgba(52, 120, 216, 0.28); outline-offset: 2px;
}

/* ── Context Menu ── */
.ctx-menu {
  position: absolute; z-index: 60;
  min-width: 200px; max-width: 260px;
  padding: 6px;
  border: 1px solid rgba(190, 205, 224, 0.62);
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255,255,255,0.4) inset;
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  animation: ctxIn 140ms cubic-bezier(.22,.61,.36,1);
  transform-origin: top left;
}
.ctx-menu.hidden { display: none; }
@keyframes ctxIn { 0% { opacity: 0; transform: scale(0.92); } 100% { opacity: 1; transform: scale(1); } }

.ctx-section { display: grid; gap: 2px; }
.ctx-divider {
  height: 1px; margin: 5px 6px;
  background: var(--line);
}

.ctx-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 7px 8px;
  border: 0; border-radius: var(--r-sm);
  color: var(--ink-soft); background: transparent;
  font-size: 12px; font-weight: 500; text-align: left;
  cursor: pointer; transition: all 100ms ease;
}
.ctx-item:hover, .ctx-item:focus-visible {
  color: var(--ink);
  background: rgba(52, 120, 216, 0.06);
}
.ctx-item:active { background: rgba(52, 120, 216, 0.11); }
.ctx-item:focus-visible { outline: 2px solid rgba(52, 120, 216, 0.28); outline-offset: 1px; }

.ctx-icon {
  width: 18px; height: 18px; display: grid; place-items: center;
  flex-shrink: 0; font-size: 13px; color: var(--muted);
}
.ctx-item kbd {
  margin-left: auto; flex-shrink: 0;
  padding: 1px 5px; border-radius: 4px;
  background: #f1f5fa; color: var(--muted-soft);
  font-size: 9px; font-weight: 700; letter-spacing: 0.3px;
  font-family: var(--font-ui);
}

/* ── Pitch Pill (Floating Teleprompter) ── */
.pitch-pill {
  position: absolute; left: 50%; bottom: 22px; z-index: 30;
  width: min(460px, calc(100vw - 40px));
  transform: translateX(-50%);
  padding: 8px 10px 10px;
  border: 1px solid rgba(190, 205, 224, 0.45);
  border-radius: var(--r-xl);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,0.3) inset;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  animation: pitchPillIn 320ms cubic-bezier(.22,.61,.36,1);
  overflow: hidden;
}
.pitch-pill.hidden { display: none; }
@keyframes pitchPillIn { 0% { opacity: 0; transform: translateX(-50%) translateY(16px) scale(0.94); } 100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); } }

/* Progress — ultra-thin line at top of pill */
.pitch-pill-progress {
  position: absolute; top: 0; left: 8px; right: 8px; height: 2px;
  border-radius: 0 0 2px 2px;
  background: rgba(52, 120, 216, 0.06);
  overflow: hidden;
}
.pitch-pill-progress-fill {
  width: 0%; height: 100%;
  background: linear-gradient(90deg, #3478d8, #19a974);
  transition: width 300ms cubic-bezier(.22,.61,.36,1);
}

/* Main row: prev · title · next · counter · close */
.pitch-pill-row {
  display: flex; align-items: center; gap: 6px;
  margin-top: 4px;
}

.pitch-pill-nav {
  width: 34px; height: 34px; flex-shrink: 0;
  display: grid; place-items: center;
  border: 0; border-radius: var(--r-md);
  color: var(--ink-soft); background: transparent;
  cursor: pointer;
  transition: all 160ms ease;
}
.pitch-pill-nav:hover {
  color: var(--blue);
  background: rgba(52, 120, 216, 0.06);
}
.pitch-pill-nav:active { background: rgba(52, 120, 216, 0.12); transform: scale(0.94); }
.pitch-pill-nav:disabled { opacity: 0.25; cursor: default; }
.pitch-pill-nav:disabled:hover { color: var(--ink-soft); background: transparent; }
.pitch-pill-nav:focus-visible { outline: 2px solid rgba(52, 120, 216, 0.28); outline-offset: 1px; }

.pitch-pill-title {
  flex: 1; min-width: 0; margin: 0;
  font-family: var(--font-title);
  font-size: 19px; font-weight: 600; line-height: 1.1;
  letter-spacing: -0.2px;
  color: #1a2d45;
  text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.pitch-pill-counter {
  flex-shrink: 0;
  min-width: 46px; text-align: center;
  font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.pitch-pill-close {
  width: 34px; height: 34px; flex-shrink: 0;
  display: grid; place-items: center;
  border: 0; border-radius: var(--r-md);
  color: var(--muted-soft); background: transparent;
  cursor: pointer;
  transition: all 160ms ease;
}
.pitch-pill-close:hover {
  color: var(--red);
  background: rgba(224, 93, 93, 0.06);
}
.pitch-pill-close:active { background: rgba(224, 93, 93, 0.14); transform: scale(0.94); }
.pitch-pill-close:focus-visible { outline: 2px solid rgba(224, 93, 93, 0.30); outline-offset: 1px; }

/* Cue — subtle subtitle below the main row */
.pitch-pill-cue {
  margin: 4px 4px 0;
  color: var(--muted);
  font-size: 13px; font-weight: 440; line-height: 1.4;
  text-align: center;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

/* Cmd overlay hidden class — reuse for compat */
.pitch-panel.hidden { display: none; }

/* ── Breadcrumb ── */
.breadcrumb {
  position: absolute; left: 76px; bottom: 26px; z-index: 10;
  max-width: min(600px, calc(100vw - 340px));
  padding: 8px 12px;
  border: 1px solid rgba(190, 205, 224, 0.50);
  border-radius: var(--r-md);
  color: #2b3b55;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 11px; font-weight: 500; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: opacity 400ms ease;
}
.breadcrumb.is-auto-hidden { opacity: 0; pointer-events: none; }
@keyframes breadIn { 0% { opacity: 0; transform: translateY(8px); } 100% { opacity: 1; transform: translateY(0); } }

/* ── Status ── */
.status {
  position: absolute; right: 18px; top: 18px; z-index: 9;
  padding: 6px 10px;
  border: 1px solid rgba(190, 205, 224, 0.45);
  border-radius: var(--r-full);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.62);
  box-shadow: var(--shadow-sm);
  font-size: 11px; font-weight: 500;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* ── Mini Map ── */
.minimap {
  position: absolute; right: 18px; bottom: 18px; z-index: 10;
  width: 220px; height: 150px;
  border-radius: var(--r-lg); overflow: hidden;
  box-shadow: var(--shadow-lg);
  transition: box-shadow 220ms ease;
}
.minimap:hover { box-shadow: var(--shadow-lg), 0 0 0 1px rgba(52, 120, 216, 0.15); }
.minimap svg { display: block; width: 100%; height: 100%; }
.mini-bg { fill: rgba(255,255,255,0.82); stroke: rgba(190,205,224,0.64); stroke-width: 1; }
.mini-node { fill: #9fb2ca; opacity: 0.78; }
.mini-link { fill: none; stroke: #b7c5d8; stroke-width: 1; opacity: 0.64; }
.mini-viewport { fill: rgba(52,120,216,0.08); stroke: #3478d8; stroke-width: 2; transition: all 180ms ease; }

/* ═══════════════════════ Editor Toolbar ═══════════════════════ */
.editor-toolbar {
  position: absolute; left: 50%; top: 14px; z-index: 35;
  display: flex; align-items: center; gap: 4px;
  padding: 6px 8px;
  border: 1px solid rgba(190, 205, 224, 0.45);
  border-radius: var(--r-xl);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(255,255,255,0.3) inset;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transform: translateX(-50%);
  animation: editorTbIn 280ms cubic-bezier(.22,.61,.36,1);
}
.editor-toolbar.hidden { display: none; }
@keyframes editorTbIn { 0% { opacity: 0; transform: translateX(-50%) translateY(-12px); } 100% { opacity: 1; transform: translateX(-50%) translateY(0); } }

.editor-status {
  display: flex; align-items: center; gap: 6px;
  padding: 0 6px;
  color: var(--ink-soft); font-size: 12px; font-weight: 650;
  border-right: 1px solid var(--line); margin-right: 4px; padding-right: 10px;
}
.editor-dirty-dot { font-size: 10px; color: var(--muted); transition: color 200ms ease; }
.editor-dirty-dot.is-dirty { color: var(--green); }

.editor-tb-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 8px;
  border: 0; border-radius: var(--r-sm);
  color: var(--ink-soft); background: transparent;
  font-size: 12px; font-weight: 550; cursor: pointer;
  transition: all 140ms ease;
}
.editor-tb-btn:hover { background: rgba(52, 120, 216, 0.06); color: var(--blue); }
.editor-tb-btn:active { background: rgba(52, 120, 216, 0.12); }
.editor-tb-btn:disabled { opacity: 0.30; cursor: default; }
.editor-tb-btn:disabled:hover { background: transparent; color: var(--ink-soft); }
.editor-tb-btn:focus-visible { outline: 2px solid rgba(52, 120, 216, 0.28); outline-offset: 1px; }
.editor-tb-close:hover { background: rgba(224, 93, 93, 0.06); color: var(--red); }

.editor-tb-sep { width: 1px; height: 20px; background: var(--line); margin: 0 2px; }

/* ═══════════════════════ Editor Popover (anchored to node) ═══════════════════════ */
.editor-popover {
  position: absolute; z-index: 40; width: 280px;
  border: 1px solid rgba(190, 205, 224, 0.50);
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255,255,255,0.35) inset;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: popoverIn 180ms cubic-bezier(.22,.61,.36,1);
  transform-origin: top center;
  pointer-events: auto;
}
.editor-popover.hidden { display: none; }
@keyframes popoverIn { 0% { opacity: 0; transform: scale(0.90) translateY(-8px); } 100% { opacity: 1; transform: scale(1) translateY(0); } }

.editor-popover-arrow {
  position: absolute; top: -7px; left: 50%; transform: translateX(-50%);
  width: 14px; height: 7px;
  background: rgba(255,255,255,0.88);
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  border-left: 1px solid rgba(190,205,224,0.50);
  border-right: 1px solid rgba(190,205,224,0.50);
}

.editor-popover-body {
  display: grid; gap: 6px; padding: 10px;
}

.editor-pop-label {
  width: 100%; padding: 7px 8px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--ink); background: rgba(247,250,255,0.7);
  font-size: 13px; font-weight: 600; font-family: var(--font-ui);
  outline: none;
}
.editor-pop-label:focus { border-color: rgba(52,120,216,0.40); box-shadow: 0 0 0 2px rgba(52,120,216,0.06); }

.editor-pop-text {
  width: 100%; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--ink-soft); background: rgba(247,250,255,0.7);
  font-size: 12px; font-family: var(--font-ui); line-height: 1.4;
  resize: vertical; outline: none;
}
.editor-pop-text:focus { border-color: rgba(52,120,216,0.40); box-shadow: 0 0 0 2px rgba(52,120,216,0.06); }

.editor-pop-row {
  display: flex; gap: 4px; align-items: center;
}
.editor-pop-row select {
  flex: 1; padding: 6px 4px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--ink-soft); background: rgba(247,250,255,0.7);
  font-size: 11px; font-weight: 550; font-family: var(--font-ui);
  outline: none; cursor: pointer;
}
.editor-pop-row select:focus { border-color: rgba(52,120,216,0.40); }

.editor-pop-upload {
  width: 30px; height: 30px; flex-shrink: 0;
  display: grid; place-items: center;
  border: 1px dashed var(--line-strong); border-radius: var(--r-sm);
  color: var(--muted); cursor: pointer;
  transition: all 120ms ease;
}
.editor-pop-upload:hover { border-color: var(--blue); color: var(--blue); background: rgba(52,120,216,0.04); }

.editor-pop-images {
  display: flex; gap: 4px; flex-wrap: wrap;
}
.editor-pop-image {
  position: relative; width: 48px; height: 36px; flex-shrink: 0;
  border-radius: 4px; overflow: hidden;
  border: 1px solid var(--line);
}
.editor-pop-image img { width: 100%; height: 100%; object-fit: cover; }
.editor-pop-image-del {
  position: absolute; top: -4px; right: -4px;
  width: 16px; height: 16px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  color: #fff; background: var(--red);
  font-size: 9px; cursor: pointer;
}

.editor-pop-actions {
  display: flex; gap: 6px;
}
.editor-pop-save {
  flex: 1; padding: 7px;
  border: 0; border-radius: var(--r-sm);
  color: #fff; background: var(--blue);
  font-size: 12px; font-weight: 650; cursor: pointer;
  transition: background 120ms ease;
}
.editor-pop-save:hover { background: #2b6ec8; }
.editor-pop-delete {
  flex: 1; padding: 7px;
  border: 1px solid rgba(224,93,93,0.25); border-radius: var(--r-sm);
  color: var(--red); background: transparent;
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 120ms ease;
}
.editor-pop-delete:hover { background: #fef5f5; border-color: rgba(224,93,93,0.45); }

/* ═══════════════════════ History Panel ═══════════════════════ */
.history-panel {
  position: absolute; right: 20px; top: 76px; z-index: 40;
  width: min(380px, calc(100vw - 40px));
  max-height: calc(100vh - 120px); overflow-y: auto;
  border: 1px solid rgba(190, 205, 224, 0.55);
  border-radius: var(--r-xl);
  background: rgba(255, 255, 255, 0.90);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  animation: nodePanelIn 220ms cubic-bezier(.22,.61,.36,1);
}
.history-panel.hidden { display: none; }

.history-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.history-header h3 { margin: 0; font-size: 14px; font-weight: 650; color: var(--ink); }
.history-close {
  width: 28px; height: 28px; display: grid; place-items: center;
  border: 0; border-radius: var(--r-sm); color: var(--muted); background: transparent;
  cursor: pointer;
}
.history-close:hover { color: var(--red); background: rgba(224,93,93,0.06); }

.history-list { padding: 8px 12px; display: grid; gap: 4px; max-height: 360px; overflow-y: auto; }
.history-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border: 1px solid transparent; border-radius: var(--r-md);
  background: transparent; cursor: pointer;
  transition: all 120ms ease;
}
.history-item:hover { border-color: var(--line); background: rgba(247,250,255,0.6); }
.history-item.is-selected { border-color: rgba(52,120,216,0.30); background: rgba(52,120,216,0.04); }
.history-item-dot {
  width: 8px; height: 8px; flex-shrink: 0; border-radius: 50%;
  background: var(--line-strong);
}
.history-item.is-recent .history-item-dot { background: var(--green); }
.history-item-content { flex: 1; min-width: 0; }
.history-item-label { font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.2; }
.history-item-time { font-size: 11px; color: var(--muted); margin-top: 2px; }
.history-item-actions { display: flex; gap: 4px; flex-shrink: 0; }
.history-item-btn {
  padding: 4px 8px; border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--muted); background: #fff; font-size: 10px; font-weight: 650; cursor: pointer;
  transition: all 120ms ease;
}
.history-item-btn:hover { border-color: var(--blue); color: var(--blue); }
.history-item-btn.is-danger:hover { border-color: rgba(224,93,93,0.40); color: var(--red); }

.history-footer {
  display: grid; gap: 6px; padding: 10px 14px 14px;
  border-top: 1px solid var(--line);
}

/* ═══════════════════════ Login Modal ═══════════════════════ */
.login-modal {
  position: absolute; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: overlayIn 180ms ease;
}
.login-modal.hidden { display: none; }

.login-card {
  width: min(340px, calc(100vw - 40px));
  display: grid; gap: 14px;
  padding: 24px;
  border: 1px solid rgba(190, 205, 224, 0.50);
  border-radius: var(--r-xl);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  animation: paletteIn 220ms cubic-bezier(.22,.61,.36,1);
  text-align: center;
}

.login-title { margin: 0; font-family: var(--font-title); font-size: 22px; color: #1a2d45; }
.login-desc { margin: 0; color: var(--muted); font-size: 13px; }

.login-input {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  color: var(--ink); background: rgba(247,250,255,0.7);
  font-size: 16px; font-family: var(--font-ui); text-align: center;
  letter-spacing: 4px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.login-input:focus { border-color: rgba(52,120,216,0.40); box-shadow: 0 0 0 3px rgba(52,120,216,0.06); }
.login-input.is-error { border-color: rgba(224,93,93,0.50); animation: shake 360ms ease; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 50%{transform:translateX(6px)} 75%{transform:translateX(-4px)} }

.login-error { color: var(--red); font-size: 12px; min-height: 0; }
.login-btn {
  width: 100%; padding: 11px;
  border: 0; border-radius: var(--r-md);
  color: #fff; background: var(--blue);
  font-size: 14px; font-weight: 650; cursor: pointer;
  transition: background 120ms ease;
}
.login-btn:hover { background: #2b6ec8; }

.login-hint { margin: 0; color: var(--muted-soft); font-size: 11px; }

/* ═══════════════════════ Analytics Dashboard ═══════════════════════ */
.analytics-dash {
  position: absolute; inset: 0; z-index: 90;
  display: grid; grid-template-rows: auto 1fr;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: overlayIn 200ms ease;
}
.analytics-dash.hidden { display: none; }

.analytics-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.analytics-header h2 { margin: 0; flex: 1; font-family: var(--font-title); font-size: 22px; color: #1a2d45; }
.analytics-header-actions { display: flex; align-items: center; gap: 8px; }
.analytics-hdr-btn {
  padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--ink-soft); background: #fff; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 120ms ease;
}
.analytics-hdr-btn:hover { border-color: rgba(52,120,216,0.38); background: #eef6ff; }
.analytics-hdr-btn.is-danger:hover { border-color: rgba(224,93,93,0.40); color: var(--red); background: #fef5f5; }
.analytics-close {
  width: 30px; height: 30px; display: grid; place-items: center;
  border: 0; border-radius: var(--r-sm); color: var(--muted); background: transparent; cursor: pointer;
}
.analytics-close:hover { color: var(--red); background: rgba(224,93,93,0.06); }

.analytics-body {
  overflow-y: auto; padding: 20px;
  display: grid; gap: 24px; align-content: start;
}

.analytics-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px;
}
.analytics-card {
  padding: 16px;
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: #fff;
}
.analytics-card-value { font-size: 28px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.analytics-card-label { font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 550; }

.analytics-section h3 { margin: 0 0 10px; font-size: 14px; font-weight: 650; color: var(--ink-soft); }

.analytics-chapters { display: grid; gap: 6px; }
.analytics-chapter-row { display: flex; align-items: center; gap: 10px; }
.analytics-chapter-label { width: 160px; flex-shrink: 0; font-size: 12px; font-weight: 550; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.analytics-chapter-bar-wrap { flex: 1; height: 20px; border-radius: 4px; background: #f0f4f9; overflow: hidden; }
.analytics-chapter-bar { height: 100%; border-radius: 4px; background: linear-gradient(90deg, #3478d8, #19a974); transition: width 400ms ease; }
.analytics-chapter-count { width: 50px; flex-shrink: 0; font-size: 11px; font-weight: 650; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.analytics-features { display: flex; gap: 12px; flex-wrap: wrap; }
.analytics-feature-item { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--r-full); font-size: 12px; color: var(--ink-soft); background: #fff; }
.analytics-feature-item strong { color: var(--ink); font-variant-numeric: tabular-nums; }

.analytics-timeline { display: flex; align-items: flex-end; gap: 2px; height: 80px; }
.analytics-timeline-bar { flex: 1; border-radius: 2px 2px 0 0; background: var(--blue); min-height: 2px; opacity: 0.7; transition: opacity 120ms ease; }
.analytics-timeline-bar:hover { opacity: 1; }

.analytics-sessions-table { font-size: 12px; }
.analytics-session-row { display: grid; grid-template-columns: 140px 80px 1fr; gap: 12px; padding: 6px 0; border-bottom: 1px solid #f5f7fb; align-items: center; }
.analytics-session-row:first-child { font-weight: 650; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.analytics-session-date { color: var(--ink-soft); }
.analytics-session-dur { color: var(--ink); font-weight: 550; font-variant-numeric: tabular-nums; }
.analytics-session-info { color: var(--muted); text-align: right; }

/* ── Empty State ── */
.empty-state {
  position: absolute; inset: 0; display: grid; place-items: center;
  padding: 24px; color: var(--muted); text-align: center; font-weight: 450;
}

/* ── Responsive ── */
@media (max-width: 860px) {
  .cmd-palette { width: calc(100vw - 24px); max-height: calc(100vh - 32px); border-radius: var(--r-lg); }
  .cmd-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cmd-chapters { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .cmd-trigger { left: 12px; bottom: 16px; }
  .breadcrumb { left: 60px; bottom: 18px; max-width: calc(100vw - 240px); }

  .pitch-pill { width: calc(100vw - 24px); bottom: 12px; }
  .pitch-pill-title { font-size: 17px; }
  .pitch-pill-cue { font-size: 12px; }
  .editor-toolbar { top: 8px; gap: 2px; padding: 4px 6px; }
  .editor-tb-btn { padding: 5px 6px; font-size: 11px; }
  .editor-tb-btn span { display: none; }
  .editor-popover { width: 260px; }
  .editor-tb-sep { margin: 0 1px; }
  .editor-status { font-size: 11px; padding-right: 6px; }

  .status { right: 10px; top: 10px; }
  .minimap { right: 10px; bottom: 10px; width: 150px; height: 104px; }
  .splash-emblem { width: 56px; height: 56px; border-radius: 16px; }
  .splash-title { font-size: 22px; }
}

@media (max-width: 480px) {
  .cmd-palette { padding: var(--s-3); }
  .cmd-actions { grid-template-columns: 1fr 1fr; }
  .minimap { display: none; }
  .breadcrumb { left: 52px; max-width: calc(100vw - 76px); }
}
