* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  overflow: hidden;
  height: 100vh;
}

header {
  background: #16213e;
  border-bottom: 1px solid #0f3460;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 100;
  flex-wrap: wrap;
  gap: 8px;
}

header h1 {
  font-size: 18px;
  color: #e94560;
  font-weight: 700;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.header-actions button,
.header-actions .header-link {
  padding: 6px 12px;
  border: 1px solid #0f3460;
  border-radius: 6px;
  background: #1a1a2e;
  color: #e0e0e0;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
}

.header-actions .header-link {
  border-color: #7c3aed;
  color: #c4b5fd;
}

.header-actions button:hover,
.header-actions .header-link:hover {
  background: #0f3460;
}

#logoutBtn { border-color: #e94560; color: #e94560; }
#logoutBtn:hover { background: #e94560; color: white; }

/* Hamburger menu toggle - hidden on desktop */
.menu-toggle {
  display: none;
  background: none;
  border: 1px solid #0f3460;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 22px;
  padding: 4px 10px;
  cursor: pointer;
  line-height: 1;
}

.menu-toggle:hover {
  background: #0f3460;
}

/* View Tabs */
.view-tabs {
  display: flex;
  gap: 4px;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  padding: 3px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.view-tab {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #888;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.2s;
}

.view-tab:hover {
  color: #e0e0e0;
  background: rgba(255,255,255,0.05);
}

.view-tab.active {
  background: #e94560;
  color: white;
  font-weight: 600;
}

#canvas {
  position: relative;
  width: 100vw;
  height: calc(100vh - 53px);
  overflow: auto;
  touch-action: pan-x pan-y;
}

#canvas-inner {
  position: relative;
  width: 4000px;
  height: 3000px;
  transform-origin: 0 0;
}

#arrows {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

#arrows line, #arrows path {
  stroke-width: 2;
  fill: none;
}

#arrows marker path {
  fill: #555;
}

#nodes {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Zoom Controls */
#zoom-controls {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  padding: 4px;
  z-index: 200;
}

#zoom-controls button {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 6px;
  background: #1a1a2e;
  color: #e0e0e0;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

#zoom-controls button:hover {
  background: #0f3460;
}

#zoomFitBtn {
  font-size: 12px !important;
  font-weight: 500 !important;
  width: auto !important;
  padding: 0 10px !important;
}

#zoomLevel {
  font-size: 12px;
  color: #888;
  min-width: 40px;
  text-align: center;
  user-select: none;
}

/* Node Card */
.node {
  position: absolute;
  width: 260px;
  border-radius: 10px;
  padding: 16px;
  cursor: grab;
  user-select: none;
  z-index: 10;
  transition: box-shadow 0.2s;
  border: 1px solid rgba(255,255,255,0.1);
}

.node:hover {
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  z-index: 20;
}

.node.dragging {
  cursor: grabbing;
  box-shadow: 0 12px 48px rgba(0,0,0,0.6);
  z-index: 100;
  opacity: 0.92;
}

.node-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.node-header h3 {
  font-size: 15px;
  font-weight: 700;
  flex: 1;
}

.node-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(0,0,0,0.3);
  white-space: nowrap;
  margin-left: 8px;
}

.node-body {
  font-size: 12px;
  line-height: 1.6;
  color: rgba(255,255,255,0.8);
}

.node-body ul {
  list-style: none;
  padding: 0;
}

.node-body li {
  padding: 3px 0;
  padding-left: 14px;
  position: relative;
}

.node-body li::before {
  content: '>';
  position: absolute;
  left: 0;
  color: rgba(255,255,255,0.4);
  font-size: 10px;
}

.edit-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,0.3);
  border: none;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  opacity: 0;
  transition: opacity 0.2s;
}

.node:hover .edit-btn { opacity: 1; }
.edit-btn:hover { background: rgba(0,0,0,0.5); color: white; }

/* Section Labels */
.section-label {
  position: absolute;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: rgba(255,255,255,0.15);
  z-index: 0;
  pointer-events: none;
}

/* Modal */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden { display: none; }

.modal-content {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 480px;
}

.modal-content h2 {
  margin-bottom: 20px;
  font-size: 20px;
  color: #e94560;
}

.modal-content label {
  display: block;
  font-size: 13px;
  color: #888;
  margin-bottom: 6px;
  margin-top: 14px;
}

.modal-content input[type="text"],
.modal-content textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #0f3460;
  border-radius: 6px;
  background: #1a1a2e;
  color: #e0e0e0;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: vertical;
}

.modal-content input:focus,
.modal-content textarea:focus { border-color: #e94560; }

.color-picks {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.color-pick {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: border-color 0.2s;
}

.color-pick.active { border-color: white; }
.color-pick:hover { border-color: rgba(255,255,255,0.5); }

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 24px;
  justify-content: flex-end;
}

.btn-primary {
  padding: 10px 24px;
  background: #e94560;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.btn-secondary {
  padding: 10px 24px;
  background: transparent;
  color: #888;
  border: 1px solid #333;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.btn-delete {
  padding: 10px 24px;
  background: transparent;
  color: #e94560;
  border: 1px solid #e94560;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  margin-right: auto;
}

.btn-primary:hover { background: #c73652; }
.btn-secondary:hover { background: #222; }
.btn-delete:hover { background: #e94560; color: white; }

/* Mobile Responsive */
@media (max-width: 768px) {
  header {
    padding: 8px 12px;
    gap: 0;
    flex-wrap: nowrap;
  }

  header h1 {
    font-size: 14px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Show hamburger, hide actions and tabs by default */
  .menu-toggle {
    display: block;
    margin-left: 8px;
  }

  .view-tabs,
  .header-actions {
    display: none;
  }

  /* When menu is open, show tabs + actions in a dropdown */
  header.menu-open .view-tabs,
  header.menu-open .header-actions {
    display: flex;
  }

  header.menu-open {
    flex-wrap: wrap;
  }

  header.menu-open .view-tabs {
    order: 10;
    width: 100%;
    justify-content: center;
    margin-top: 8px;
    flex-wrap: wrap;
  }

  header.menu-open .header-actions {
    order: 11;
    width: 100%;
    justify-content: center;
    margin-top: 6px;
    flex-wrap: wrap;
  }

  .view-tab {
    padding: 6px 12px;
    font-size: 12px;
  }

  .header-actions button,
  .header-actions .header-link {
    padding: 6px 10px;
    font-size: 12px;
  }

  /* Canvas fills below header */
  #canvas {
    height: calc(100vh - 45px);
  }

  .node {
    width: 220px;
    padding: 12px;
  }

  .node-header h3 {
    font-size: 13px;
  }

  .node-body {
    font-size: 11px;
  }

  .modal-content {
    margin: 16px;
    padding: 20px;
  }

  /* Larger zoom controls on touch */
  #zoom-controls {
    bottom: 16px;
    right: 16px;
    left: 16px;
    justify-content: center;
    gap: 6px;
    padding: 6px;
  }

  #zoom-controls button {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }

  #zoomFitBtn {
    font-size: 13px !important;
    padding: 0 14px !important;
    height: 44px !important;
  }

  #zoomLevel {
    font-size: 13px;
    min-width: 48px;
  }

  .edit-btn {
    opacity: 1;
    padding: 6px 10px;
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  header h1 {
    font-size: 13px;
  }

  .node {
    width: 200px;
    padding: 10px;
  }

  .node-header h3 {
    font-size: 12px;
  }
}
