/* ═══════════════════════════════════════════
   BASE
   ═══════════════════════════════════════════ */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: #080810; font-family: system-ui, -apple-system, sans-serif; overflow: hidden; }

/* ═══════════════════════════════════════════
   MAP CANVAS
   ═══════════════════════════════════════════ */
#canvas {
  position: fixed; top: 52px; left: 0;
  width: 100vw; height: calc(100vh - 52px);
  cursor: grab;
}
#canvas:active { cursor: grabbing; }
#label-layer {
  position: fixed; top: 52px; left: 0;
  pointer-events: none; overflow: hidden;
  width: 100vw; height: calc(100vh - 52px);
}
#tooltip {
  position: fixed; pointer-events: none;
  background: rgba(10,10,20,0.95); color: #e0e0f0;
  padding: 8px 12px; border-radius: 6px; font-size: 13px;
  border: 0.5px solid rgba(255,255,255,0.2);
  display: none; max-width: 220px; line-height: 1.4;
  z-index: 200;
}
#zoom-level { position: fixed; bottom: 20px; right: 80px; color: rgba(255,255,255,0.2); font-size: 11px; z-index: 100; pointer-events: none; }
#node-count { position: fixed; bottom: 36px; right: 80px; color: rgba(255,255,255,0.2); font-size: 11px; z-index: 100; pointer-events: none; }


/* ═══════════════════════════════════════════
   MONUMENT VALLEY PALETTE
   ------------------------------------------
   Warm cream:       #F2EDE6
   Dusty terracotta: #C4826A
   Dusty lavender:   #9B8FB5
   Sage green:       #8BAD7E
   Deep charcoal:    #3A3028
   Mid warm brown:   #8A7E72
   Border:           rgba(58,48,40,0.10)
   ═══════════════════════════════════════════ */

/* ── TOP BAR ──────────────────────────────── */
#top-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 52px;
  background: linear-gradient(to right, #F5EAE3 0%, #EDE6F0 55%, #E4EBF5 100%);
  border-bottom: 1px solid rgba(58,48,40,0.09);
  box-shadow: 0 2px 16px rgba(58,48,40,0.07);
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px;
  z-index: 400;
}

.topbar-logo {
  display: flex; align-items: center; gap: 9px;
  text-decoration: none; flex-shrink: 0;
}
.topbar-logo-icon {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, #D4906A 0%, #C4729A 100%);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.topbar-logo-text {
  font-size: 14px; font-weight: 650;
  color: #3A3028; letter-spacing: -0.3px;
  white-space: nowrap;
}

.topbar-right {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
  margin-left: auto;
}

.topbar-search-wrap { position: relative; }
.topbar-search-wrap .search-icon {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  color: #B0A496; pointer-events: none;
}
#search-box {
  background: rgba(58,48,40,0.07);
  border: 1px solid rgba(58,48,40,0.11);
  border-radius: 8px;
  padding: 6px 28px 6px 30px;
  font-size: 12px; color: #3A3028;
  width: 180px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
#search-box::placeholder { color: #B8AFA8; }
#search-box:focus {
  background: #fff;
  border-color: rgba(196,130,106,0.45);
  box-shadow: 0 0 0 3px rgba(196,130,106,0.10);
}

.search-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(58,48,40,0.10); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #8A7E72; font-size: 10px; line-height: 1;
  transition: background 0.12s, color 0.12s;
}
.search-clear:hover { background: rgba(58,48,40,0.18); color: #3A3028; }

.topbar-icon-btn {
  width: 32px; height: 32px; border-radius: 8px;
  background: transparent; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #9A8E86;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.topbar-icon-btn:hover { background: rgba(58,48,40,0.07); color: #3A3028; }
.topbar-burger { width: 36px; height: 36px; border-radius: 9px; }

/* ── BURGER DROPDOWN ── */
.topbar-burger-wrap { position: relative; }

.nav-dropdown {
  position: absolute; top: calc(100% + 10px); right: 0;
  min-width: 188px;
  background: linear-gradient(to bottom, #F5EAE3 0%, #EDE6F0 60%, #E4EBF5 100%);
  border: 1px solid rgba(58,48,40,0.09);
  border-radius: 12px;
  padding: 5px;
  box-shadow: 0 8px 32px rgba(58,48,40,0.14), 0 2px 8px rgba(58,48,40,0.08);
  opacity: 0;
  transform: translateY(-6px) scale(0.97);
  transform-origin: top right;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
  z-index: 500;
}
.nav-dropdown.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.nav-dropdown-item {
  width: 100%; padding: 9px 12px;
  display: flex; align-items: center; gap: 10px;
  background: transparent; border: none; cursor: pointer;
  border-radius: 8px;
  font-size: 13px; font-weight: 450; color: #3A3028;
  font-family: inherit; text-align: left;
  transition: background 0.12s, color 0.12s;
}
.nav-dropdown-item svg { color: #9A8E86; flex-shrink: 0; transition: color 0.12s; }
.nav-dropdown-item:hover { background: rgba(58,48,40,0.07); color: #2C2018; }
.nav-dropdown-item:hover svg { color: #6A5E56; }
.nav-dropdown-divider { height: 1px; background: rgba(58,48,40,0.08); margin: 4px 0; }

/* ── FLOATING CONTROLS – shared card style ── */
.ctrl-card {
  background: linear-gradient(145deg, rgba(248,242,236,0.95) 0%, rgba(237,232,246,0.95) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(58,48,40,0.10);
  border-radius: 12px;
  padding: 5px;
  box-shadow: 0 4px 20px rgba(58,48,40,0.12), 0 0 0 1px rgba(196,130,106,0.55), 0 0 28px rgba(196,130,106,0.60);
}
.ctrl-btn {
  width: 34px; height: 34px; border-radius: 8px;
  background: transparent; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #6E6358;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}
.ctrl-btn:hover { background: rgba(58,48,40,0.08); color: #3A3028; }
.ctrl-btn.active { background: rgba(196,130,106,0.14); color: #C4826A; }
.ctrl-divider { height: 1px; background: rgba(58,48,40,0.08); margin: 2px 0; }

/* ── BOTTOM-LEFT CONTROLS ── */
#ctrl-left {
  position: fixed; bottom: 24px; left: 20px;
  display: flex; flex-direction: column; gap: 0;
  z-index: 300;
}

/* ── CONTINUE LEARNING CHIP ── */
#continue-chip {
  position: fixed; bottom: 24px; left: 70px;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px 8px 10px;
  font-size: 12.5px; font-weight: 500;
  color: #3A3028;
  cursor: pointer;
  z-index: 300;
  white-space: nowrap;
  transition: opacity 0.15s, transform 0.12s;
}
#continue-chip:hover { opacity: 0.82; transform: translateY(-1px); }
#continue-chip strong { font-weight: 650; }
.continue-chip-progress {
  font-size: 11px; font-weight: 600;
  color: #C4826A;
  background: rgba(196,130,106,0.13);
  padding: 2px 7px; border-radius: 20px;
}

/* ── FILTER PANEL ── */
#filter-panel {
  position: fixed; bottom: 24px; left: 72px;
  z-index: 300;
  min-width: 210px;
  opacity: 0;
  transform: translateX(-8px) scale(0.97);
  transform-origin: left bottom;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}
#filter-panel.open {
  opacity: 1;
  transform: translateX(0) scale(1);
  pointer-events: auto;
}
.fp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px 5px;
}
.fp-title {
  font-size: 10px; font-weight: 700; letter-spacing: 0.9px;
  text-transform: uppercase; color: #8A7E72;
}
.fp-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 8px;
  cursor: pointer; user-select: none;
  transition: background 0.12s;
}
.fp-item:hover { background: rgba(58,48,40,0.06); }
.fp-item.active { background: rgba(58,48,40,0.05); }
.fp-dot {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--fi-color, #C4826A);
  background: transparent;
  transition: background 0.14s;
}
.fp-item.active .fp-dot { background: var(--fi-color, #C4826A); }
.fp-label {
  font-size: 12px; font-weight: 500; color: #3A3028; flex: 1;
  line-height: 1.3;
}
.fp-radio {
  width: 15px; height: 15px; border-radius: 50%; flex-shrink: 0;
  border: 1.5px solid rgba(58,48,40,0.18);
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.14s;
}
.fp-item.active .fp-radio {
  border-color: var(--fi-color, #C4826A);
}
.fp-item.active .fp-radio::after {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--fi-color, #C4826A);
}
.fp-clear {
  display: flex; align-items: center;
  padding: 3px 6px;
  font-size: 11px; font-weight: 600; color: #B0A496;
  cursor: pointer; border-radius: 6px;
  background: none; border: none;
  transition: color 0.12s, background 0.12s;
}
.fp-clear:hover { color: #6E6358; background: rgba(58,48,40,0.05); }
.fp-clear.hidden { display: none; }
.fp-settings-link {
  display: flex; align-items: center;
  color: #B0A496;
  text-decoration: none;
  padding: 3px 4px; border-radius: 5px;
  transition: color 0.12s, background 0.12s;
}
.fp-settings-link:hover { color: #6E6358; background: rgba(58,48,40,0.06); }
.fp-list { max-height: 260px; overflow-y: auto; padding-bottom: 4px; }

/* ── LAYER PANEL ── */
#layer-panel {
  position: fixed; bottom: 24px; left: 72px;
  z-index: 300;
  min-width: 200px;
  opacity: 0;
  transform: translateX(-8px) scale(0.97);
  transform-origin: left bottom;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}
#layer-panel.open {
  opacity: 1;
  transform: translateX(0) scale(1);
  pointer-events: auto;
}

.layer-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 8px;
  cursor: pointer; user-select: none;
  transition: background 0.12s;
}
.layer-item:hover { background: rgba(58,48,40,0.06); }

.layer-checkbox {
  width: 15px; height: 15px; border-radius: 4px; flex-shrink: 0;
  border: 1.5px solid rgba(58,48,40,0.25);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.14s, border-color 0.14s;
}
.layer-checkbox.checked {
  background: var(--lc-color, #C4826A);
  border-color: var(--lc-color, #C4826A);
}
.layer-checkbox.checked::after {
  content: '';
  display: block;
  width: 8px; height: 4px;
  border-left: 1.5px solid #fff;
  border-bottom: 1.5px solid #fff;
  transform: translateY(-1px) rotate(-45deg);
}

/* ── BOTTOM-RIGHT ZOOM ── */
#ctrl-zoom {
  position: fixed; bottom: 24px; right: 20px;
  display: flex; flex-direction: column;
  z-index: 300;
}
#ctrl-zoom .ctrl-btn {
  font-size: 20px; font-weight: 300; line-height: 1;
  width: 34px; height: 34px;
}

/* ═══════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════ */
#sidebar {
  position: fixed; top: 52px; right: 0;
  width: 320px; height: calc(100vh - 52px);
  background: linear-gradient(to bottom, #F5EAE3 0%, #EDE6F0 55%, #E4EBF5 100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  border-left: 1px solid rgba(58,48,40,0.09);
  box-shadow: -6px 0 32px rgba(58,48,40,0.09);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 350;
  overflow: hidden;
}
#sidebar.open { transform: translateX(0); }

.sb-header {
  padding: 20px 20px 0;
  position: relative;
}
.sb-breadcrumb {
  font-size: 11px; color: #B0A496;
  letter-spacing: 0.3px;
  margin-bottom: 8px;
}
.sb-domain-tag {
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 700; letter-spacing: 0.9px;
  text-transform: uppercase;
  padding: 3px 9px; border-radius: 4px;
  margin-bottom: 10px;
}
.sb-title {
  font-size: 22px; font-weight: 720;
  color: #2C2820; line-height: 1.2;
  letter-spacing: -0.4px;
  margin-bottom: 18px;
  padding-right: 32px;
}

.sb-divider { height: 1px; background: rgba(58,48,40,0.08); }

.sb-body {
  flex: 1; overflow-y: auto;
  padding: 18px 20px 28px;
  display: flex; flex-direction: column; gap: 12px;
}
.sb-body::-webkit-scrollbar { width: 3px; }
.sb-body::-webkit-scrollbar-track { background: transparent; }
.sb-body::-webkit-scrollbar-thumb { background: rgba(58,48,40,0.14); border-radius: 2px; }

/* Knowledge card */
.sb-knowledge-card {
  background: linear-gradient(135deg, #ffffff 0%, #F8F0F5 100%);
  border: 1px solid rgba(58,48,40,0.08);
  border-radius: 14px;
  padding: 16px;
}
.sb-knowledge-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.sb-knowledge-label {
  font-size: 13px; font-weight: 600; color: #3A3028;
}
.sb-knowledge-badge {
  font-size: 10px; font-weight: 700; letter-spacing: 0.6px;
  text-transform: uppercase;
  background: rgba(139,173,126,0.16); color: #5E9052;
  padding: 3px 9px; border-radius: 20px;
}
.sb-pct {
  font-size: 44px; font-weight: 700;
  color: #2C2820; line-height: 1;
  letter-spacing: -1px;
}
.sb-pct-sub {
  font-size: 11px; color: #B0A496;
  margin-top: 5px; line-height: 1.5;
}

/* Toggle row */
.sb-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, #ffffff 0%, #F0EDF8 100%);
  border: 1px solid rgba(58,48,40,0.08);
  border-radius: 14px;
  padding: 14px 16px;
}
.sb-toggle-label {
  display: flex; align-items: center; gap: 9px;
  font-size: 13px; color: #3A3028;
}
.sb-toggle-label svg { color: #9B8FB5; flex-shrink: 0; }

.sb-toggle {
  width: 40px; height: 22px; border-radius: 11px;
  background: #8BAD7E;
  position: relative;
  flex-shrink: 0;
}
.sb-toggle-thumb {
  position: absolute; top: 3px; right: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.20);
}

/* Test me button */
.sb-test-btn {
  width: 100%; padding: 13px 16px;
  background: linear-gradient(135deg, #B09CC8 0%, #9182B0 100%);
  color: #fff;
  border: none; border-radius: 14px;
  font-size: 14px; font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  letter-spacing: 0.1px;
  transition: background 0.15s, transform 0.1s;
}
.sb-test-btn:hover { background: linear-gradient(135deg, #A08CB8 0%, #8172A0 100%); transform: translateY(-1px); }
.sb-test-btn:active { transform: translateY(0); }

/* Learn this button */
.sb-learn-btn {
  width: 100%; padding: 13px 16px;
  background: linear-gradient(135deg, #2292B8 0%, #1472A0 100%);
  color: #fff;
  border: none; border-radius: 14px;
  font-size: 14px; font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  letter-spacing: 0.1px;
  transition: background 0.15s, transform 0.1s;
}
.sb-learn-btn:hover { background: linear-gradient(135deg, #1A82A8 0%, #0D6290 100%); transform: translateY(-1px); }
.sb-learn-btn:active { transform: translateY(0); }

/* Overview */
.sb-section-title {
  font-size: 11px; font-weight: 700; letter-spacing: 0.7px;
  text-transform: uppercase; color: #7A6E65;
  margin-bottom: 8px;
}
.sb-overview-text {
  font-size: 13px; color: #6E6358; line-height: 1.65;
}

/* Close button */
#sb-close {
  position: absolute; top: 16px; right: 16px;
  width: 28px; height: 28px; border-radius: 7px;
  background: rgba(58,48,40,0.07);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #8A7E72;
  transition: background 0.15s;
  z-index: 1;
}
#sb-close:hover { background: rgba(58,48,40,0.13); }

/* ═══════════════════════════════════════════
   MOBILE
   ═══════════════════════════════════════════ */
/* ── Emergent layer connector pulse ── */
@keyframes connector-pulse {
  0%, 100% { opacity: 0.25; }
  50%       { opacity: 0.55; }
}
.connector-line { animation: connector-pulse 3.5s ease-in-out infinite; }

@media (max-width: 520px) {
  .topbar-logo-text { display: none; }
}
