* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1f2937;
  overflow: hidden;
  background:
    radial-gradient(circle, #dfe8ef 1px, transparent 1px),
    #f4f8fb;
  background-size: 18px 18px;
}

#toolbar {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 20;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

button,
input[type="file"]::file-selector-button {
  border: 1px solid #d1d5db;
  background: white;
  color: #111827;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: #f3f4f6;
}

button.primary {
  background: #ff6600;
  color: white;
  border-color: #ff6600;
}

button.danger {
  color: #b91c1c;
}

#help {
  margin-left: auto;
  color: #6b7280;
  font-size: 14px;
}

#stage {
  position: fixed;
  inset: 0;
  transform-origin: 0 0;
}

svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 1;
}

.node {
  position: absolute;
  z-index: 5;
  min-width: 120px;
  max-width: 240px;
  padding: 10px 14px;
  border: 2px solid #d7dee7;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  user-select: none;
  cursor: grab;
  text-align: center;
  font-size: 14px;
  line-height: 1.25;
  outline: none;
}

.node.root {
  background: #111827;
  border-color: #111827;
  color: white;
  font-weight: 700;
}

.node.selected {
  border-color: #ff6600;
  box-shadow: 0 0 0 4px rgba(255, 102, 0, 0.18), 0 8px 24px rgba(15, 23, 42, 0.10);
}

.node[contenteditable="true"] {
  user-select: text;
  cursor: text;
}

#footer {
  position: fixed;
  left: 16px;
  bottom: 12px;
  z-index: 40;
  color: #6b7280;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  padding: 6px 10px;
}

@media (max-width: 850px) {
  #toolbar {
    flex-wrap: wrap;
  }

  #help {
    width: 100%;
    margin-left: 0;
  }
}

.front_page {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1f2937;
  background:
    radial-gradient(circle, #dfe8ef 1px, transparent 1px),
    #f4f8fb;
  background-size: 18px 18px;
}

#front_panel {
  width: min(680px, calc(100% - 32px));
  padding: 44px;
  text-align: center;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #e5e7eb;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.10);
}

#front_logo {
  width: 150px;
  height: 150px;
  margin-bottom: 18px;
}

#front_panel h1 {
  margin: 0;
  font-size: 46px;
  letter-spacing: -1px;
}

#tagline {
  margin: 12px 0 0;
  font-size: 20px;
  font-weight: 600;
  color: #ff6600;
}

#description {
  max-width: 560px;
  margin: 22px auto 30px;
  font-size: 17px;
  line-height: 1.6;
  color: #4b5563;
}

#start_button, #more_info_button {
  display: inline-block;
  padding: 14px 24px;
  border-radius: 14px;
  background: #ff6600;
  color: white;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 10px 24px rgba(255, 102, 0, 0.24);
}

#more_info_button{
  background: #551177;
  box-shadow: 0 10px 24px rgba(85, 17, 119, 0.24);
}

#start_button:hover {
  background: #e65c00;
}

#front_note {
  margin-top: 22px;
  font-size: 14px;
  color: #6b7280;
}

#front_footer {
  position: fixed;
  left: 16px;
  bottom: 12px;
  color: #6b7280;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  padding: 6px 10px;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  touch-action: none;
}

#stage {
  position: fixed;
  inset: 0;
  transform-origin: 0 0;
  cursor: grab;
}

#stage:active {
  cursor: grabbing;
}

.node {
  touch-action: none;
  cursor: grab;
}

.node[contenteditable="true"] {
  cursor: text;
}

#toolbar,
#footer {
  user-select: none;
}

#more_menu {
  position: relative;
}

#more_menu_items {
  display: none;
  position: absolute;
  top: 42px;
  right: 0;
  z-index: 100;
  min-width: 170px;
  padding: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: rgba(255,255,255,0.98);
  box-shadow: 0 12px 32px rgba(0,0,0,0.14);
}

#more_menu.open #more_menu_items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#more_menu_items button {
  width: 100%;
  text-align: left;
}

#more_menu_items #delete_node {
  color: #b91c1c;
}

body.dark_mode {
  background:
    radial-gradient(circle, #374151 1px, transparent 1px),
    #111827;
  color: #f9fafb;
}

body.dark_mode #toolbar,
body.dark_mode #more_menu_items,
body.dark_mode #footer {
  background: rgba(31, 41, 55, 0.96);
  border-color: #374151;
  color: #f9fafb;
}

body.dark_mode button {
  background: #1f2937;
  color: #f9fafb;
  border-color: #4b5563;
}

body.dark_mode button:hover {
  background: #374151;
}

body.dark_mode .node {
  background: #1f2937;
  color: #f9fafb;
  border-color: #4b5563;
}

body.dark_mode .node.root {
  background: #ff6600;
  border-color: #ff6600;
  color: #ffffff;
}

body.dark_mode .node.selected {
  border-color: #ff6600;
  box-shadow: 0 0 0 4px rgba(255, 102, 0, 0.25);
}

.info_cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 28px 0;
  text-align: left;
}

.info_cards article {
  padding: 18px;
  border-radius: 18px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
}

.info_cards h2 {
  margin: 0 0 8px;
  font-size: 18px;
  color: #ff6600;
}

.info_cards p {
  margin: 0;
  color: #4b5563;
  line-height: 1.5;
}

@media (max-width: 700px) {
  .info_cards {
    grid-template-columns: 1fr;
  }
}
