/* ===== Mind map editor ===== */
.editor-page {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--header-height));
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.editor-toolbar__group--main {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.toolbar-btn--big {
  padding: 12px 20px;
  min-height: 48px;
  font-size: 1rem;
  border-radius: 12px;
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  min-height: 40px;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  transition: background var(--transition), transform 0.15s ease;
}

.toolbar-btn:hover:not(:disabled) {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  transform: translateY(-1px);
}

.toolbar-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.toolbar-btn--primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.toolbar-btn--primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
  color: #fff;
}

.toolbar-btn--accent {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
  font-weight: 700;
}

.toolbar-btn--accent:hover:not(:disabled) {
  background: #bbf7d0;
}

.toolbar-btn--danger:hover:not(:disabled) {
  background: #fef2f2;
  border-color: var(--color-danger);
  color: var(--color-danger);
}

.toolbar-hint {
  margin-left: auto;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-primary);
  padding: 8px 16px;
  background: var(--color-primary-light);
  border-radius: 999px;
}

/* 가지 추가 — 모양 선택 메뉴 */
.add-child-wrap {
  position: relative;
}

.add-child-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 200;
  min-width: 280px;
  padding: 12px;
  background: #fff;
  border: 2px solid var(--color-border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}

.add-child-menu__title {
  margin: 0 0 10px;
  padding: 0 4px;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--color-text-muted);
}

.add-child-option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 6px;
  font-family: inherit;
  text-align: left;
  background: #f8fafc;
  border: 2px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.add-child-option:last-child {
  margin-bottom: 0;
}

.add-child-option:hover,
.add-child-option:focus-visible {
  background: #eef2ff;
  border-color: #c7d2fe;
  outline: none;
}

.add-child-option:active {
  transform: scale(0.98);
}

.add-child-option__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.add-child-option__text strong {
  font-size: 0.9375rem;
  font-weight: 800;
  color: var(--color-text);
}

.add-child-option__text span {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.mm-shape-preview {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 36px;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.mm-shape-preview--pill {
  border-radius: 999px;
  color: #fff;
}

.mm-shape-preview--rect {
  border-radius: 6px;
  color: #fff;
}

.mm-shape-preview--postit {
  border-radius: 2px 2px 2px 0;
  color: #334155;
  box-shadow: 2px 3px 8px rgba(0, 0, 0, 0.18);
  transform: rotate(-1.5deg);
}

.shape-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shape-picker__option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  font-family: inherit;
  text-align: left;
  background: #f8fafc;
  border: 2px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.shape-picker__option.is-active {
  background: #eef2ff;
  border-color: var(--color-primary);
}

.shape-picker__option:hover:not(.is-active) {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.shape-picker__label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.shape-picker__label strong {
  font-size: 0.875rem;
  font-weight: 800;
}

.shape-picker__label span {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.editor-workspace {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: auto;
  background: radial-gradient(circle at 1px 1px, #cbd5e1 1px, transparent 0);
  background-size: 24px 24px;
  background-color: #eef2f7;
}

.slide-area {
  display: flex;
  align-items: stretch;
  gap: 16px;
  max-width: 100%;
}

.slide-area__main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.slide-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px 16px;
  width: 100%;
  padding: 4px 0;
}

.slide-nav__btn {
  min-width: 96px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text);
  background: #fff;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  box-shadow: var(--shadow-sm);
}

.slide-nav__btn:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #94a3b8;
}

.slide-nav__btn:active:not(:disabled) {
  transform: scale(0.98);
}

.slide-nav__btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.slide-nav__btn--delete {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fff5f5;
}

.slide-nav__btn--delete:hover:not(:disabled) {
  background: #fef2f2;
  border-color: #f87171;
}

.slide-nav__indicator {
  min-width: 72px;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.85);
  padding: 8px 14px;
  border-radius: 999px;
  border: 2px solid var(--color-border);
}

.slide-add-btn {
  flex-shrink: 0;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 72px;
  min-height: 120px;
  padding: 14px 10px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.3;
  color: #7c3aed;
  background: #fff;
  border: 2px dashed #c4b5fd;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  box-shadow: var(--shadow-sm);
}

.slide-add-btn:hover {
  background: #f5f3ff;
  border-color: #7c3aed;
}

.slide-add-btn:active {
  transform: scale(0.97);
}

.slide-add-btn__icon {
  font-size: 1.75rem;
  font-weight: 400;
  line-height: 1;
}

.slide-add-btn__text {
  text-align: center;
}

.a4-frame--export .a4-frame__label,
.a4-frame--export .mm-curve-handle {
  display: none !important;
}

.a4-frame--export .mm-node.is-selected {
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.a4-frame--export .mm-node--root.is-selected {
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.35);
}

/* A4 흰 화면 — 모든 편집은 이 안에서만 */
.a4-frame {
  width: min(calc(100vw - 40px), calc((100vh - var(--header-height) - 140px) * var(--a4-landscape-ratio)));
  max-width: 100%;
  background: #fff;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
  border: 2px solid #cbd5e1;
}

.a4-frame__sizer {
  width: 100%;
  padding-top: calc(210 / 297 * 100%);
  pointer-events: none;
  visibility: hidden;
}

.a4-frame__label {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  background: rgba(255, 255, 255, 0.9);
  padding: 4px 10px;
  border-radius: 999px;
  z-index: 10;
  pointer-events: none;
  border: 1px solid var(--color-border);
}

.mindmap-stage {
  position: absolute;
  inset: 0;
  z-index: 2;
  touch-action: none;
}

.mindmap-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.mindmap-handles {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.mindmap-handles .mm-curve-handle {
  pointer-events: auto;
}

.mm-curve-handle {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f97316;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px #f97316, 0 2px 8px rgba(0, 0, 0, 0.2);
  cursor: grab;
  z-index: 15;
  transition: transform 0.12s ease;
}

.mm-curve-handle:hover {
  transform: translate(-50%, -50%) scale(1.2);
  background: #ea580c;
}

.mindmap-stage.is-curve-dragging .mm-curve-handle {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.25);
}

.mindmap-stage.is-curve-edit .mm-curve-handle {
  animation: pulse-handle 1.5s ease infinite;
}

@keyframes pulse-handle {
  0%, 100% { box-shadow: 0 0 0 2px #f97316, 0 2px 8px rgba(0, 0, 0, 0.2); }
  50% { box-shadow: 0 0 0 6px rgba(249, 115, 22, 0.35), 0 2px 8px rgba(0, 0, 0, 0.2); }
}

.curve-slider {
  width: 100%;
  height: 8px;
  accent-color: #f97316;
  cursor: pointer;
  margin: 8px 0;
}

.curve-slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 10px;
}

.btn-curve-reset {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-curve-reset:hover {
  background: #fff7ed;
  border-color: #f97316;
  color: #ea580c;
}

.toolbar-btn.is-active {
  background: #ffedd5;
  border-color: #f97316;
  color: #c2410c;
}

.mindmap-nodes {
  position: absolute;
  inset: 0;
  z-index: 3;
}

/* 알약 모양 노드 — 참고 이미지 스타일 */
.mm-node {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 10px 22px;
  border-radius: 999px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  cursor: grab;
  user-select: none;
  max-width: 220px;
  text-align: center;
  word-break: keep-all;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  border: 2px solid transparent;
  z-index: 10;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mm-node--shape-rect {
  border-radius: 8px;
  white-space: normal;
  max-width: 200px;
  min-width: 80px;
}

.mm-node--shape-postit {
  position: absolute;
  border-radius: 2px 2px 2px 0;
  box-shadow: 2px 4px 10px rgba(0, 0, 0, 0.18);
  transform: translate(-50%, -50%) rotate(-1.5deg);
  white-space: normal;
  max-width: 190px;
  min-width: 76px;
  overflow: visible;
  text-overflow: unset;
}

.mm-node--shape-postit::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  background: linear-gradient(135deg, transparent 50%, rgba(0, 0, 0, 0.1) 50%);
  pointer-events: none;
}

.mm-node--root {
  font-size: 20px;
  font-weight: 800;
  padding: 14px 32px;
  max-width: 260px;
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.35);
}

.mm-node--branch {
  font-size: 15px;
  font-weight: 700;
  padding: 10px 20px;
}

.mm-node--leaf {
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  opacity: 0.95;
}

.mm-node.is-selected {
  border-color: #1e293b;
  box-shadow: 0 0 0 4px rgba(30, 41, 59, 0.2), 0 4px 12px rgba(0, 0, 0, 0.2);
}

.mindmap-stage.is-dragging .mm-node {
  cursor: grabbing;
}

.mindmap-stage.is-dragging .mm-node.is-selected {
  opacity: 0.92;
}

/* 사이드바 */
.editor-sidebar {
  width: 300px;
  flex-shrink: 0;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  padding: 24px 20px;
  overflow-y: auto;
}

.editor-sidebar__title {
  font-size: 1.125rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--color-text);
}

.editor-sidebar__label {
  display: block;
  font-size: 0.9375rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--color-text);
}

.editor-sidebar__field {
  margin-bottom: 20px;
}

.editor-sidebar__input--big {
  padding: 14px 16px;
  font-size: 1.0625rem;
  font-weight: 600;
  border-width: 2px;
  border-radius: 12px;
}

.editor-sidebar__input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
}

.editor-sidebar__input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.color-picker-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px var(--color-border);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.color-swatch:hover {
  transform: scale(1.12);
}

.color-swatch.is-active {
  box-shadow: 0 0 0 3px var(--color-text);
  transform: scale(1.15);
}

.editor-help--steps {
  margin-top: 8px;
  padding: 18px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  line-height: 1.8;
}

.editor-help strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 12px;
  color: var(--color-text);
}

.help-steps {
  margin: 0 0 12px 20px;
  padding: 0;
}

.help-steps li {
  margin-bottom: 8px;
}

.help-note {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  font-weight: 600;
}

.editor-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1e293b;
  color: #fff;
  padding: 14px 28px;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 600;
  z-index: 9999;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.toast.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

@media (max-width: 900px) {
  .editor-body {
    flex-direction: column;
  }

  .editor-sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--color-border);
  }

  .toolbar-hint {
    width: 100%;
    margin-left: 0;
    text-align: center;
  }

  .slide-area {
    flex-direction: column;
    align-items: center;
    width: 100%;
  }

  .slide-add-btn {
    flex-direction: row;
    width: 100%;
    max-width: 280px;
    min-height: auto;
    padding: 12px 20px;
  }

  .slide-add-btn__text br {
    display: none;
  }
}
