

@font-face {
  font-family: 'NaiPaoTi';
  src: url('/fonts/LeMiXiaoNaiPaoTi.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-hand: 'NaiPaoTi', 'Kaiti SC', 'STKaiti', 'KaiTi', 'Segoe Print', 'Comic Sans MS', 'PingFang SC', cursive;

  --paper: #f7f1e3;
  --paper-2: #efe6d0;
  --paper-3: #fdfaf1;
  --ink: #33302b;
  --ink-soft: #7a7263;
  --ink-faint: #a89f8d;
  --accent: #e07856;
  --accent-soft: #f3c9b8;
  --blue: #4a7fa5;

  --done-bg: #e4efd2;
  --done-border: #7da86b;
  --partial-bg: #fdf1cf;
  --partial-border: #d4a94e;

  --wobble: 255px 15px 225px 15px / 15px 225px 15px 255px;
  --wobble-sm: 12px 4px 10px 4px / 4px 10px 4px 12px;
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-hand);
  color: var(--ink);
  background: var(--paper);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: var(--font-hand);
  cursor: pointer;
}

input,
textarea {
  font-family: var(--font-hand);
  color: var(--ink);
}

.rough-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}



.app {
  display: flex;
  height: 100%;
}

.main {
  flex: 1;
  min-width: 0;
  height: 100%;
  position: relative;
}



.btn-hand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--paper-3);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: var(--wobble);
  font-size: 0.95rem;
  line-height: 1.2;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  box-shadow: 2px 3px 0 rgba(51, 48, 43, 0.18);
  white-space: nowrap;
}

.btn-hand:hover:not(:disabled) {
  transform: rotate(-1deg) translateY(-1px);
  box-shadow: 3px 4px 0 rgba(51, 48, 43, 0.22);
}

.btn-hand:active:not(:disabled) {
  transform: rotate(0.5deg) translateY(1px);
  box-shadow: 1px 1px 0 rgba(51, 48, 43, 0.18);
}

.btn-hand:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--ink);
  color: #fff;
}

.btn-danger {
  background: #d9534f;
  border-color: var(--ink);
  color: #fff;
}

.btn-small {
  padding: 6px 10px;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

.btn-link {
  background: none;
  border: none;
  color: var(--blue);
  font-family: var(--font-hand);
  font-size: 0.9rem;
  padding: 8px 0;
  text-decoration: underline wavy;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: var(--paper-3);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: var(--wobble-sm);
  font-size: 1rem;
  line-height: 1;
  transition: transform 0.08s ease;
}

.icon-btn:hover:not(:disabled) {
  transform: rotate(-4deg);
}

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

.icon-btn.danger {
  border-color: transparent;
  background: transparent;
  color: var(--ink-faint);
}

.icon-btn.danger:hover {
  color: #c0392b;
  border-color: #c0392b;
  background: #fdf3f2;
}

.input-hand {
  width: 100%;
  padding: 9px 12px;
  background: var(--paper-3);
  border: 2px solid var(--ink);
  border-radius: var(--wobble-sm);
  font-size: 1rem;
  outline: none;
}

.input-hand:focus {
  border-color: var(--accent);
  box-shadow: 2px 3px 0 rgba(224, 120, 86, 0.25);
}

.field-label {
  display: block;
  margin: 10px 0 6px;
  font-size: 0.9rem;
  color: var(--ink-soft);
}



.canvas-root {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  background: var(--paper);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.canvas-root:active {
  cursor: grabbing;
}

.canvas-grid {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(51, 48, 43, 0.22) 1.1px, transparent 1.6px);
  pointer-events: none;
}

.canvas-world {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.empty-canvas {
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-hint {
  font-size: 1.3rem;
  color: var(--ink-soft);
  transform: rotate(-2deg);
  border: 2px dashed var(--ink-faint);
  padding: 24px 32px;
  border-radius: var(--wobble);
}



.node-card {
  position: absolute;
  background: var(--paper-3);
  border: 2.2px solid var(--ink);
  border-radius: var(--wobble);
  filter: url(#rough-1);
  box-shadow: 3px 4px 0 rgba(51, 48, 43, 0.16);
  padding: 8px 10px 6px;
  cursor: grab;
  transition: box-shadow 0.12s ease, border-color 0.12s ease;
}

.node-card:active {
  cursor: grabbing;
}

.node-card.selected {
  border-color: var(--accent);
  border-width: 2.6px;
  box-shadow: 4px 5px 0 rgba(224, 120, 86, 0.35);
}

.node-card.status-done {
  background: var(--done-bg);
  border-color: var(--done-border);
}

.node-card.status-partial {
  background: var(--partial-bg);
  border-color: var(--partial-border);
}

.node-head {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.checkbox {
  flex-shrink: 0;
  width: 21px;
  height: 21px;
  margin-top: 2px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fffdf6;
  border: 2px solid var(--ink);
  border-radius: 45% 55% 50% 50% / 50% 45% 55% 50%;
  color: #2e6b35;
  cursor: pointer;
  transition: transform 0.08s ease;
}

.checkbox:hover {
  transform: rotate(-8deg) scale(1.1);
}

.checkbox.done {
  background: #b9d8a8;
  border-color: #5d8a4e;
}

.checkbox.partial {
  background: #f0d894;
  border-color: #b08d3a;
  color: #8a6a1f;
}

.node-text {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-hand);
  font-size: 1.02rem;
  line-height: 1.45;
  color: var(--ink);
  padding: 1px 2px;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
}

.node-text.done {
  text-decoration: line-through wavy rgba(93, 138, 78, 0.85);
  color: #55714a;
}

.node-head-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.node-head-actions .icon-btn {
  width: 26px;
  height: 26px;
  border-width: 1.6px;
  font-size: 0.75rem;
}

.node-foot {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.mini-btn {
  padding: 4px 10px;
  background: #fffdf6;
  border: 1.6px solid var(--ink);
  border-radius: var(--wobble-sm);
  font-size: 0.85rem;
  color: var(--ink);
  transition: transform 0.08s ease;
}

.mini-btn:hover {
  transform: rotate(-2deg);
  background: var(--paper);
}

.mini-btn.sparkle {
  background: #fff3e6;
  border-color: var(--accent);
  color: #b4542f;
}

.node-badge {
  margin-top: 7px;
  padding: 3px 8px;
  border-top: 1.6px dashed var(--ink-faint);
  font-size: 0.8rem;
  color: var(--ink-soft);
  text-align: center;
}

.node-badge.collapsed {
  border-top: none;
  background: #fff3e6;
  border: 1.6px solid var(--accent);
  border-radius: var(--wobble-sm);
  color: #b4542f;
  font-weight: bold;
}



.edges-layer {
  position: absolute;
  pointer-events: none;
  overflow: visible;
}

.edge path {
  fill: none;
  stroke: #8f8571;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: none;
}

.edge-arrow {
  fill: #8f8571;
  stroke: #8f8571;
  stroke-width: 0.8;
}



.ui-layer {
  pointer-events: auto;
}

.topbar {
  position: absolute;
  top: 12px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

.menu-btn {
  flex-shrink: 0;
}

.canvas-title {
  flex: 1;
  min-width: 0;
  pointer-events: auto;
}

.title-text {
  display: inline-block;
  margin: 0;
  padding: 6px 14px 6px 10px;
  font-size: 1.45rem;
  font-weight: normal;
  background: rgba(247, 241, 227, 0.92);
  border: 2px solid transparent;
  border-radius: var(--wobble-sm);
  cursor: text;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.title-text:hover {
  border-color: var(--ink-faint);
  background: var(--paper-3);
}

.title-input {
  width: 300px;
  max-width: 60vw;
  font-size: 1.3rem;
  padding: 5px 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(247, 241, 227, 0.9);
  border: 2px solid var(--ink);
  border-radius: var(--wobble);
  padding: 6px 8px;
  box-shadow: 2px 3px 0 rgba(51, 48, 43, 0.15);
  flex-shrink: 0;
}

.zoom-controls {
  position: absolute;
  right: 16px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: rgba(247, 241, 227, 0.92);
  border: 2px solid var(--ink);
  border-radius: var(--wobble);
  padding: 8px 6px;
  box-shadow: 2px 3px 0 rgba(51, 48, 43, 0.15);
}

.zoom-label {
  font-size: 0.8rem;
  color: var(--ink-soft);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  letter-spacing: 1px;
}

.canvas-hint {
  position: absolute;
  left: 14px;
  bottom: 14px;
  font-size: 0.82rem;
  color: var(--ink-faint);
  background: rgba(247, 241, 227, 0.85);
  padding: 4px 10px;
  border-radius: var(--wobble-sm);
  pointer-events: none;
}



.sidebar {
  width: 264px;
  flex-shrink: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--paper-2);
  border-right: 2.5px solid var(--ink);
  z-index: 40;
  transition: transform 0.22s ease;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px 8px 16px;
}

.logo {
  font-size: 1.35rem;
  font-weight: bold;
  letter-spacing: 1px;
}

.new-canvas-btn {
  margin: 4px 12px 10px;
}

.canvas-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 12px;
}

.list-empty {
  color: var(--ink-soft);
  font-size: 0.9rem;
  padding: 14px 8px;
  text-align: center;
  border: 2px dashed var(--ink-faint);
  border-radius: var(--wobble-sm);
  margin: 4px;
}

.canvas-group {
  margin-bottom: 10px;
}

.group-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 4px;
  font-size: 0.82rem;
  color: var(--ink-soft);
  letter-spacing: 1px;
}

.group-count {
  background: rgba(51, 48, 43, 0.08);
  border-radius: 999px;
  padding: 0 7px;
  font-size: 0.75rem;
}

.canvas-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 8px 7px 10px;
  margin: 2px 0;
  border: 2px solid transparent;
  border-radius: var(--wobble-sm);
  cursor: pointer;
  transition: background 0.1s ease, transform 0.1s ease;
}

.canvas-row:hover {
  background: rgba(253, 250, 241, 0.7);
}

.canvas-row.active {
  background: var(--paper-3);
  border-color: var(--ink);
  box-shadow: 2px 2px 0 rgba(51, 48, 43, 0.15);
  transform: rotate(-0.4deg);
}

.canvas-row.drop-target {
  border-color: var(--accent);
  border-style: dashed;
}

.row-emoji {
  flex-shrink: 0;
  font-size: 1rem;
}

.row-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.95rem;
}

.row-rename-input {
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  font-size: 0.9rem;
}

.row-menu-btn {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  font-size: 1rem;
  color: var(--ink-soft);
  opacity: 0.65;
}

.row-menu-btn:hover {
  opacity: 1;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-top: 2px dashed var(--ink-faint);
  background: rgba(253, 250, 241, 0.5);
}

.user-avatar {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  border: 2px solid var(--ink);
  border-radius: 45% 55% 50% 50% / 50% 45% 55% 50%;
  font-size: 1.15rem;
  font-weight: bold;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-email {
  font-size: 0.78rem;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


.row-menu {
  position: fixed;
  z-index: 60;
  min-width: 150px;
  background: var(--paper-3);
  border: 2px solid var(--ink);
  border-radius: var(--wobble-sm);
  box-shadow: 3px 4px 0 rgba(51, 48, 43, 0.2);
  padding: 4px;
}

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  background: none;
  border: none;
  border-radius: var(--wobble-sm);
  font-size: 0.9rem;
  color: var(--ink);
}

.menu-item:hover {
  background: var(--paper);
}

.menu-item.danger {
  color: #c0392b;
}

.menu-item.danger:hover {
  background: #fdf3f2;
}

.menu-sub {
  position: relative;
}

.submenu {
  display: none;
  position: absolute;
  left: calc(100% + 2px);
  top: 0;
  min-width: 140px;
  background: var(--paper-3);
  border: 2px solid var(--ink);
  border-radius: var(--wobble-sm);
  box-shadow: 3px 4px 0 rgba(51, 48, 43, 0.2);
  padding: 4px;
  z-index: 61;
}

.menu-sub:hover .submenu,
.menu-sub:focus-within .submenu {
  display: block;
}

.sidebar-backdrop {
  display: none;
}



.modal-root {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(51, 48, 43, 0.35);
  backdrop-filter: blur(2px);
  padding: 16px;
}

.modal-card {
  width: 100%;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--wobble);
  filter: url(#rough-1);
  box-shadow: 6px 8px 0 rgba(51, 48, 43, 0.28);
  padding: 20px 22px;
  transform: rotate(-0.5deg);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.modal-title {
  font-size: 1.3rem;
  margin-bottom: 12px;
  border-bottom: 2px dashed var(--ink-faint);
  padding-bottom: 8px;
}

.confirm-message {
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 16px;
}

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



.login-form {
  display: flex;
  flex-direction: column;
}

.login-tip {
  font-size: 0.88rem;
  color: var(--ink-soft);
  line-height: 1.5;
  margin: 0 0 6px;
}

.dev-code {
  display: block;
  margin-top: 6px;
  color: #b4542f;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  color: var(--ink-faint);
  font-size: 0.85rem;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  border-top: 2px dashed var(--ink-faint);
}

.btn-google {
  background: #fffdf6;
}

.google-g {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #4285f4;
  color: #4285f4;
  font-weight: bold;
  font-size: 0.8rem;
}



.decompose-tip {
  font-size: 0.92rem;
  color: var(--ink-soft);
  line-height: 1.55;
  margin: 0 0 10px;
}

.decompose-prompt {
  resize: vertical;
  font-size: 0.95rem;
}

.context-details {
  margin-top: 10px;
}

.context-details summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--ink-soft);
  user-select: none;
}

.context-pre {
  margin: 8px 0 0;
  padding: 10px 12px;
  background: var(--paper-2);
  border: 2px dashed var(--ink-faint);
  border-radius: var(--wobble-sm);
  font-size: 0.82rem;
  line-height: 1.6;
  max-height: 170px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.decompose-loading {
  text-align: center;
  padding: 26px 0 14px;
}

.pencil {
  font-size: 2.2rem;
  display: inline-block;
  animation: wobble-pencil 0.9s ease-in-out infinite;
}

@keyframes wobble-pencil {
  0%, 100% { transform: rotate(-14deg) translateY(0); }
  50% { transform: rotate(8deg) translateY(-6px); }
}

.decompose-loading p {
  margin: 10px 0 0;
  font-size: 1.05rem;
}

.loading-sub {
  font-size: 0.85rem !important;
  color: var(--ink-soft);
}

.result-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 300px;
  overflow-y: auto;
}

.result-list li {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 8px 10px;
  margin: 4px 0;
  border: 2px solid transparent;
  border-radius: var(--wobble-sm);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1.4;
}

.result-list li:hover {
  background: rgba(253, 250, 241, 0.8);
}

.result-list li.checked {
  background: var(--done-bg);
  border-color: var(--done-border);
}

.mini-check {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--ink);
  border-radius: 40% 60% 55% 45% / 50% 45% 55% 50%;
  font-size: 0.72rem;
  color: #2e6b35;
  background: #fffdf6;
}

.mini-check.on {
  background: #b9d8a8;
}



.share-link-row {
  display: flex;
  gap: 8px;
  margin: 8px 0;
}

.share-link-row .input-hand {
  flex: 1;
  font-size: 0.85rem;
}

.share-note {
  font-size: 0.82rem;
  color: var(--ink-soft);
}



.toast-stack {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: max-content;
  max-width: 92vw;
}

.toast {
  background: var(--paper-3);
  border: 2px solid var(--ink);
  border-radius: var(--wobble-sm);
  box-shadow: 3px 4px 0 rgba(51, 48, 43, 0.22);
  padding: 9px 16px;
  font-size: 0.92rem;
  animation: toast-in 0.25s ease;
  transform: rotate(-0.5deg);
}

.toast-success {
  background: var(--done-bg);
  border-color: var(--done-border);
}

.toast-error {
  background: #fdeaea;
  border-color: #c0392b;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) rotate(-2deg); }
  to { opacity: 1; transform: translateY(0) rotate(-0.5deg); }
}



@media (max-width: 899px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-108%);
    box-shadow: 6px 0 0 rgba(51, 48, 43, 0.25);
  }

  .sidebar.open {
    transform: none;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(51, 48, 43, 0.3);
  }

  .canvas-hint {
    display: none;
  }
}

@media (max-width: 640px) {
  .topbar {
    top: 8px;
    left: 8px;
    right: 8px;
    gap: 6px;
  }

  .title-text {
    font-size: 1.15rem;
    padding: 5px 8px;
  }

  .topbar-actions {
    gap: 5px;
    padding: 4px 6px;
  }

  .topbar-actions .icon-btn {
    width: 30px;
    height: 30px;
  }

  .topbar-actions .btn-small {
    padding: 5px 7px;
    font-size: 0.78rem;
  }

  .zoom-controls {
    right: 10px;
    bottom: 16px;
  }

  .modal-card {
    padding: 16px;
  }

  .node-card {
    min-height: 96px;
  }

  .mini-btn {
    padding: 6px 10px;
    font-size: 0.88rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pencil {
    animation: none;
  }

  .toast {
    animation: none;
  }
}
