* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #111827;
}

body {
  background: #0f172a;
}

#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.75rem;
  background: #020617;
  border-bottom: 1px solid #1f2937;
  gap: 0.5rem;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

.toolbar button,
.toolbar select {
  font-size: 0.8rem;
}

button {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: #020617;
  color: #e5e7eb;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

button.primary {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  border-color: transparent;
  color: white;
}

button.secondary {
  background: rgba(15, 23, 42, 0.9);
}

button.small {
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
}

button:hover {
  border-color: #e5e7eb;
}

select,
input[type="number"],
input[type="text"] {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: #020617;
  color: #e5e7eb;
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  outline: none;
}

input[type="color"] {
  width: 2rem;
  height: 1.1rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: transparent;
  padding: 0;
}

.main-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr) minmax(220px, 260px);
  gap: 0.5rem;
  padding: 0.5rem;
  background: radial-gradient(circle at top left, #1f2937, #020617);
}

.side-panel {
  background: rgba(15, 23, 42, 0.92);
  border-radius: 1rem;
  border: 1px solid rgba(55, 65, 81, 0.9);
  padding: 0.75rem 0.85rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: calc(100vh - 3.5rem);
  overflow: hidden;
}

.side-panel h2 {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #9ca3af;
  margin: 0 0 0.2rem;
}

.panel-section {
  border-radius: 0.8rem;
  background: radial-gradient(circle at top left, rgba(31, 41, 55, 0.9), rgba(15, 23, 42, 0.96));
  border: 1px solid rgba(55, 65, 81, 0.85);
  padding: 0.6rem 0.7rem;
  margin-bottom: 0.4rem;
}

.panel-section h3 {
  font-size: 0.8rem;
  font-weight: 600;
  color: #e5e7eb;
  margin: 0 0 0.3rem;
}

.panel-section label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: #d1d5db;
  margin-bottom: 0.25rem;
  gap: 0.35rem;
}

.panel-section label span.label-text {
  flex: 1;
}

.panel-section label > input,
.panel-section label > select {
  flex-shrink: 0;
}

.panel-section .field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
}

.panel-section .field-row span {
  font-size: 0.78rem;
  color: #d1d5db;
}

.panel-section .field-row input[type="number"] {
  max-width: 4rem;
}

.panel-subsection {
  border-top: 1px dashed rgba(75, 85, 99, 0.9);
  margin-top: 0.45rem;
  padding-top: 0.35rem;
}

.panel-subsection h4 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9ca3af;
  margin: 0 0 0.25rem;
}

.inline-checkbox {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: #d1d5db;
  margin-bottom: 0.25rem;
}

.inline-number-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.inline-number-row input[type="number"] {
  max-width: 3.2rem;
}

.inline-number-row .suffix {
  font-size: 0.78rem;
  color: #9ca3af;
}

.small-note {
  font-size: 0.72rem;
  color: #9ca3af;
  margin: 0.4rem 0 0;
}

.canvas-wrapper {
  position: relative;
  border-radius: 1rem;
  border: 1px solid rgba(55, 65, 81, 0.9);
  overflow: hidden;
  background: radial-gradient(circle at top left, #0f172a, #020617);
}

#mindmapCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: default;
}

#hintOverlay {
  position: absolute;
  left: 0.75rem;
  bottom: 0.75rem;
  font-size: 0.72rem;
  color: rgba(209, 213, 219, 0.85);
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(17, 24, 39, 0.98));
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(75, 85, 99, 0.9);
  pointer-events: none;
}

.tab-bar {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.6rem 0;
  background: transparent;
}

.tab {
  border-radius: 999px;
  border: 1px solid transparent;
  background: rgba(15, 23, 42, 0.85);
  color: #9ca3af;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
}

.tab.active {
  border-color: rgba(59, 130, 246, 0.9);
  background: radial-gradient(circle at top left, rgba(37, 99, 235, 0.22), rgba(15, 23, 42, 0.98));
  color: #e5e7eb;
}

.tab-close {
  font-size: 0.8rem;
  opacity: 0.8;
}

.inline-node-editor {
  position: fixed;
  z-index: 20;
  resize: none;
  border-radius: 14px;
  border: 2px solid rgba(37, 99, 235, 0.9);
  padding: 6px 9px;
  font-size: 0.85rem;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #111827;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.45);
  outline: none;
}

@media (max-width: 960px) {
  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .main-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(260px, 1.2fr) auto;
  }

  .side-panel {
    max-height: none;
  }
}
