:root {
  --mm-bg-top: #f8eee5;
  --mm-bg-bottom: #fffdf8;
  --mm-surface: rgba(255, 253, 247, 0.92);
  --mm-panel-border: rgba(92, 67, 47, 0.1);
  --mm-panel-shadow: 0 24px 60px rgba(80, 45, 18, 0.1);
  --mm-text: #2f241d;
  --mm-muted: #7a6a5f;
  --mm-accent: #0f766e;
  --mm-accent-soft: rgba(15, 118, 110, 0.12);
  --mm-danger: #dc2626;
  --mm-canvas: linear-gradient(180deg, rgba(255, 246, 239, 0.98), rgba(255, 255, 255, 0.95));
  --mm-scroll-track: rgba(234, 221, 209, 0.72);
  --mm-scroll-thumb: linear-gradient(180deg, rgba(15, 118, 110, 0.78), rgba(74, 179, 168, 0.88));
  --mm-scroll-thumb-hover: linear-gradient(180deg, rgba(13, 97, 90, 0.88), rgba(48, 153, 142, 0.94));
}

body.theme-neon.mindmap-body,
body.mindmap-body.theme-neon {
  --mm-bg-top: #071421;
  --mm-bg-bottom: #06111c;
  --mm-surface: rgba(9, 24, 38, 0.86);
  --mm-panel-border: rgba(126, 240, 255, 0.16);
  --mm-panel-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --mm-text: #e6f4ff;
  --mm-muted: #9fb5c6;
  --mm-accent: #6cf2df;
  --mm-accent-soft: rgba(108, 242, 223, 0.12);
  --mm-canvas: linear-gradient(180deg, rgba(7, 18, 28, 0.96), rgba(6, 17, 26, 0.98));
  --mm-scroll-track: rgba(12, 28, 42, 0.72);
  --mm-scroll-thumb: linear-gradient(180deg, rgba(108, 242, 223, 0.8), rgba(126, 240, 255, 0.9));
  --mm-scroll-thumb-hover: linear-gradient(180deg, rgba(126, 240, 255, 0.92), rgba(108, 242, 223, 0.96));
}

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

body.mindmap-body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  font-family: "Baloo 2", system-ui, sans-serif;
  font-size: 13px;
  color: var(--mm-text);
  background:
    radial-gradient(circle at top left, rgba(255, 208, 170, 0.35), transparent 28%),
    radial-gradient(circle at top right, rgba(183, 233, 226, 0.34), transparent 24%),
    linear-gradient(180deg, var(--mm-bg-top), var(--mm-bg-bottom));
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 118, 110, 0.82) rgba(234, 221, 209, 0.66);
}

body.mindmap-body::-webkit-scrollbar,
.mindmap-sidebar::-webkit-scrollbar,
.mindmap-context-menu::-webkit-scrollbar,
.mindmap-modal-card::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

body.mindmap-body::-webkit-scrollbar-track,
.mindmap-sidebar::-webkit-scrollbar-track,
.mindmap-context-menu::-webkit-scrollbar-track,
.mindmap-modal-card::-webkit-scrollbar-track {
  background: var(--mm-scroll-track);
  border-radius: 999px;
}

body.mindmap-body::-webkit-scrollbar-thumb,
.mindmap-sidebar::-webkit-scrollbar-thumb,
.mindmap-context-menu::-webkit-scrollbar-thumb,
.mindmap-modal-card::-webkit-scrollbar-thumb {
  background: var(--mm-scroll-thumb);
  border-radius: 999px;
  border: 2px solid rgba(255, 248, 241, 0.92);
}

body.mindmap-body::-webkit-scrollbar-thumb:hover,
.mindmap-sidebar::-webkit-scrollbar-thumb:hover,
.mindmap-context-menu::-webkit-scrollbar-thumb:hover,
.mindmap-modal-card::-webkit-scrollbar-thumb:hover {
  background: var(--mm-scroll-thumb-hover);
}

.mindmap-shell {
  width: min(100%, 1460px);
  padding: 14px 18px 18px;
  height: calc(100vh - 92px);
  margin: 0 auto;
  min-height: 0;
}

.mindmap-layout {
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  gap: 16px;
  height: 100%;
  min-height: 0;
  align-items: stretch;
}

.panel {
  background: var(--mm-surface);
  border: 1px solid var(--mm-panel-border);
  box-shadow: var(--mm-panel-shadow);
  border-radius: 18px;
  backdrop-filter: blur(12px);
}

.mindmap-sidebar {
  padding: 16px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 118, 110, 0.82) rgba(234, 221, 209, 0.66);
}

.sidebar-head h1,
.sidebar-group h2,
.modal-head h3 {
  margin: 0;
}

.sidebar-head p,
.guide-list,
.cache-card,
.modal-copy,
.ai-card p,
.toolbar-label,
.toolbar-meta span,
.menu-title,
.ai-status {
  margin: 0;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mm-accent);
  background: rgba(15, 118, 110, 0.1);
}

.sidebar-head {
  padding: 12px;
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(255, 241, 228, 0.96), rgba(244, 252, 251, 0.92));
  border: 1px solid rgba(92, 67, 47, 0.08);
}

.sidebar-head h1 {
  margin-top: 8px;
  font-size: clamp(1.05rem, 1.2vw, 1.35rem);
  line-height: 0.95;
}

.sidebar-head p {
  margin-top: 8px;
  color: var(--mm-muted);
  line-height: 1.45;
  font-size: 0.88rem;
}

.sidebar-group {
  padding: 11px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(92, 67, 47, 0.08);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-group h2 {
  font-size: 0.8rem;
}

.button-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn,
.menu-actions button,
.chip-row button,
.swatch-grid button,
.icon-button {
  font: inherit;
}

.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 7px 9px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background 0.16s ease;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.82rem;
}

.btn:hover:not(:disabled),
.menu-actions button:hover,
.chip-row button:hover,
.swatch-grid button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.56;
  cursor: not-allowed;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #0f766e, #0ea5a4);
  box-shadow: 0 10px 18px rgba(15, 118, 110, 0.18);
}

.btn-ghost {
  color: var(--mm-text);
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(92, 67, 47, 0.12);
}

.btn-inline {
  min-height: 0;
  padding: 5px 8px;
  border-radius: 10px;
}

.guide-list {
  padding-left: 18px;
  color: var(--mm-muted);
  line-height: 1.45;
  font-size: 0.78rem;
}

.cache-card {
  display: none;
  padding: 10px 12px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255, 240, 230, 0.88), rgba(240, 251, 249, 0.95));
  border: 1px solid rgba(92, 67, 47, 0.08);
  line-height: 1.45;
  color: var(--mm-muted);
  font-size: 0.74rem;
}

.cache-card.is-off {
  background: linear-gradient(135deg, rgba(255, 241, 196, 0.95), rgba(255, 250, 228, 0.95));
  color: #6f4b00;
}

.mindmap-stage {
  position: relative;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: hidden;
  min-width: 0;
}

.stage-toolbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 6px 2px;
}

.toolbar-label {
  color: var(--mm-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stage-toolbar strong {
  font-size: 0.8rem;
  line-height: 1.3;
}

.toolbar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.toolbar-meta span {
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(92, 67, 47, 0.08);
  color: var(--mm-muted);
  font-size: 0.7rem;
}

body.theme-neon.mindmap-body .mindmap-shell .panel,
body.mindmap-body.theme-neon .mindmap-shell .panel {
  background: linear-gradient(180deg, rgba(8, 21, 34, 0.94), rgba(9, 24, 38, 0.9));
  border-color: rgba(108, 242, 223, 0.18);
  box-shadow:
    0 22px 52px rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255,255,255,0.03);
}

body.theme-neon.mindmap-body .sidebar-head,
body.mindmap-body.theme-neon .sidebar-head {
  background:
    radial-gradient(circle at 16% 0%, rgba(108, 242, 223, 0.12), transparent 34%),
    linear-gradient(180deg, rgba(12, 31, 47, 0.96), rgba(10, 24, 37, 0.94));
  border-color: rgba(108, 242, 223, 0.16);
}

body.theme-neon.mindmap-body .sidebar-head h1,
body.theme-neon.mindmap-body .sidebar-group h2,
body.mindmap-body.theme-neon .sidebar-head h1,
body.mindmap-body.theme-neon .sidebar-group h2 {
  color: #ecfeff;
}

body.theme-neon.mindmap-body .sidebar-head p,
body.theme-neon.mindmap-body .guide-list,
body.theme-neon.mindmap-body .cache-card,
body.theme-neon.mindmap-body .toolbar-label,
body.theme-neon.mindmap-body .toolbar-meta span,
body.mindmap-body.theme-neon .sidebar-head p,
body.mindmap-body.theme-neon .guide-list,
body.mindmap-body.theme-neon .cache-card,
body.mindmap-body.theme-neon .toolbar-label,
body.mindmap-body.theme-neon .toolbar-meta span {
  color: #b9d4e4;
}

body.theme-neon.mindmap-body .sidebar-group,
body.mindmap-body.theme-neon .sidebar-group {
  background: rgba(17, 38, 55, 0.92);
  border-color: rgba(108, 242, 223, 0.12);
}

body.theme-neon.mindmap-body .eyebrow,
body.mindmap-body.theme-neon .eyebrow {
  background: rgba(108, 242, 223, 0.14);
  color: #8df5ea;
}

body.theme-neon.mindmap-body .btn-ghost,
body.mindmap-body.theme-neon .btn-ghost {
  background: rgba(18, 43, 60, 0.94);
  border-color: rgba(108, 242, 223, 0.14);
  color: #e6f4ff;
}

body.theme-neon.mindmap-body .btn-ghost:hover:not(:disabled),
body.mindmap-body.theme-neon .btn-ghost:hover:not(:disabled) {
  background: rgba(23, 53, 73, 0.98);
  border-color: rgba(108, 242, 223, 0.28);
}

body.theme-neon.mindmap-body .btn-primary,
body.mindmap-body.theme-neon .btn-primary {
  background: linear-gradient(135deg, #14b8a6, #0891b2);
  box-shadow: 0 12px 24px rgba(8, 145, 178, 0.26);
}

body.theme-neon.mindmap-body .btn:disabled,
body.mindmap-body.theme-neon .btn:disabled {
  opacity: 0.42;
  background: rgba(148, 163, 184, 0.12);
  color: rgba(226, 232, 240, 0.52);
  border-color: rgba(148, 163, 184, 0.12);
}

body.theme-neon.mindmap-body .toolbar-meta span,
body.mindmap-body.theme-neon .toolbar-meta span {
  background: rgba(13, 31, 46, 0.9);
  border-color: rgba(108, 242, 223, 0.12);
}

.mindmap-canvas {
  position: relative;
  overflow: hidden;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  border-radius: 20px;
  border: 1px solid rgba(92, 67, 47, 0.12);
  background: var(--mm-canvas);
  cursor: grab;
  touch-action: none;
  user-select: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.mindmap-canvas.is-panning,
.mindmap-canvas.is-node-dragging {
  cursor: grabbing;
}

.mindmap-grid-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(92, 67, 47, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(92, 67, 47, 0.035) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: radial-gradient(circle at center, rgba(0, 0, 0, 1), transparent 88%);
}

.mindmap-scene {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--scene-size);
  height: var(--scene-size);
  transform-origin: center center;
}

.mindmap-content {
  position: relative;
  width: 100%;
  height: 100%;
}

.mindmap-connector-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.mindmap-connector {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: auto;
  cursor: context-menu;
}

.mindmap-node-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.mindmap-node {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 102px;
  min-height: 38px;
  padding: 7px 12px;
  border: 2px solid var(--node-border, rgba(92, 67, 47, 0.18));
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), var(--node-fill, #ffffff));
  color: var(--node-text, #2f241d);
  box-shadow: 0 8px 16px rgba(89, 58, 35, 0.1);
  font-size: calc(0.76rem * var(--node-font-scale, 1));
  font-weight: 700;
  line-height: 1.25;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  user-select: none;
  touch-action: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.mindmap-node:hover,
.mindmap-node.is-selected {
  transform: translate(-50%, -50%) translateY(-3px);
  box-shadow: 0 14px 24px rgba(89, 58, 35, 0.16);
}

.mindmap-node.is-selected {
  border-color: #245d57;
}

.mindmap-node[data-shape="rect"] {
  border-radius: 14px;
}

.mindmap-node[data-shape="oval"] {
  border-radius: 32px / 20px;
}

.mindmap-node[data-shape="cloud"] {
  border-radius: 28px 22px 30px 20px;
}

.mindmap-node-root {
  box-shadow: 0 14px 24px rgba(87, 63, 38, 0.14);
}

.resize-handles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #245d57;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: auto;
}

.mindmap-node.is-selected .resize-handle {
  opacity: 1;
}

.resize-handle[data-handle="top-left"] { top: 0; left: 0; cursor: nwse-resize; }
.resize-handle[data-handle="top-right"] { top: 0; left: 100%; cursor: nesw-resize; }
.resize-handle[data-handle="bottom-left"] { top: 100%; left: 0; cursor: nesw-resize; }
.resize-handle[data-handle="bottom-right"] { top: 100%; left: 100%; cursor: nwse-resize; }

.mindmap-context-menu {
  position: absolute;
  width: min(220px, calc(100vw - 24px));
  max-height: min(70vh, 560px);
  overflow: auto;
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 253, 247, 0.98);
  border: 1px solid rgba(92, 67, 47, 0.12);
  box-shadow: 0 28px 60px rgba(89, 58, 35, 0.2);
  z-index: 40;
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 118, 110, 0.82) rgba(234, 221, 209, 0.66);
}

.mindmap-context-menu[hidden],
.mindmap-modal[hidden],
.mindmap-modal-backdrop[hidden] {
  display: none !important;
}

.menu-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 8px;
}

.menu-divider {
  height: 1px;
  margin: 10px 0 12px;
  background: rgba(92, 67, 47, 0.1);
}

.menu-title {
  color: var(--mm-muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.menu-actions {
  display: grid;
  gap: 8px;
}

.menu-actions button,
.chip-row button,
.swatch-grid button {
  border: 1px solid rgba(92, 67, 47, 0.12);
  background: rgba(255, 255, 255, 0.94);
  color: var(--mm-text);
  border-radius: 14px;
  cursor: pointer;
}

.menu-actions button {
  min-height: 30px;
  padding: 6px 8px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-row button {
  min-height: 26px;
  padding: 5px 7px;
}

.chip-row button.is-active,
.menu-actions button.is-active,
.swatch-grid button.is-active {
  border-color: var(--mm-accent);
  box-shadow: 0 0 0 3px var(--mm-accent-soft);
}

.font-pill {
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.08);
  color: var(--mm-accent);
  font-size: 0.74rem;
  font-weight: 700;
}

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.swatch-grid-small {
  grid-template-columns: repeat(3, 1fr);
}

.swatch-grid button {
  min-height: 30px;
  padding: 5px;
}

.swatch {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  background: var(--swatch);
  border: 1px solid rgba(92, 67, 47, 0.12);
}

.node-swatch {
  background: var(--fill);
  border: 3px solid var(--stroke);
}

.custom-theme-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.custom-theme-row input[type="color"] {
  width: 46px;
  height: 34px;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid rgba(92, 67, 47, 0.15);
  background: transparent;
}

.mindmap-modal-backdrop {
  position: absolute;
  inset: 10px;
  background: rgba(32, 20, 14, 0.36);
  backdrop-filter: blur(4px);
  border-radius: 18px;
  z-index: 50;
}

.mindmap-modal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  z-index: 60;
}

.mindmap-modal-card {
  width: min(360px, calc(100vw - 32px));
  max-height: min(86vh, 760px);
  overflow: auto;
  border-radius: 16px;
  padding: 12px;
  background: linear-gradient(180deg, rgba(255, 252, 246, 0.99), rgba(255, 255, 255, 0.97));
  border: 1px solid rgba(92, 67, 47, 0.12);
  box-shadow: 0 34px 70px rgba(57, 36, 23, 0.26);
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 118, 110, 0.82) rgba(234, 221, 209, 0.66);
}

.modal-head h3,
.ai-card h4 {
  font-size: 0.9rem;
}

.ai-modal-card {
  width: min(540px, calc(100vw - 32px));
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.icon-button {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid rgba(92, 67, 47, 0.1);
  background: rgba(255, 255, 255, 0.92);
  color: var(--mm-muted);
  cursor: pointer;
}

.modal-copy {
  margin-top: 10px;
  line-height: 1.55;
  color: var(--mm-muted);
  font-size: 0.78rem;
}

.modal-field {
  margin-top: 10px;
}

.modal-field input,
.modal-field textarea,
.ai-card textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(92, 67, 47, 0.14);
  background: rgba(255, 255, 255, 0.96);
  color: var(--mm-text);
  padding: 8px 10px;
  font: inherit;
  resize: vertical;
}

.modal-field input.has-error,
.modal-field textarea.has-error {
  border-color: var(--mm-danger);
}

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

.ai-layout {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.ai-card {
  padding: 8px;
  border-radius: 12px;
  border: 1px solid rgba(92, 67, 47, 0.1);
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.ai-card.is-active {
  border-color: rgba(15, 118, 110, 0.32);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.08);
}

.ai-card.is-disabled {
  opacity: 0.48;
}

.upload-box {
  display: inline-flex;
}

.file-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--mm-muted);
  font-size: 0.88rem;
}

.ai-status {
  min-height: 1.2em;
  margin-top: 14px;
  color: var(--mm-muted);
}

.ai-status.is-error {
  color: var(--mm-danger);
}

.ai-status.is-success {
  color: #15803d;
}

@media (max-width: 1100px) {
  body.mindmap-body {
    height: auto;
    overflow: auto;
  }

  .mindmap-shell {
    width: 100%;
    height: auto;
    min-height: auto;
    padding: 12px;
  }

  .mindmap-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .mindmap-sidebar {
    order: 2;
  }

  .mindmap-stage {
    order: 1;
    min-height: 70vh;
  }

  .mindmap-canvas {
    height: 62vh;
    min-height: 460px;
  }
}

@media (max-width: 768px) {
  .mindmap-shell {
    padding: 12px;
    height: auto;
  }

  .mindmap-layout {
    gap: 12px;
  }

  .mindmap-stage {
    padding: 12px;
  }

  .mindmap-canvas {
    height: 58vh;
    min-height: 360px;
  }

  .stage-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-meta {
    justify-content: flex-start;
  }

  .ai-layout {
    grid-template-columns: 1fr;
  }

  .swatch-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .mindmap-modal {
    padding: 12px;
  }

  .mindmap-modal-backdrop {
    inset: 12px;
  }
}
