* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #f4f4f6;
  user-select: none;
  -webkit-user-select: none;
}

#canvas {
  position: fixed;
  inset: 0;
  touch-action: none;
  cursor: crosshair;
}

/* ---------- toolbar ---------- */
#toolbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 10px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid #ddd;
}
.group { display: flex; align-items: center; gap: 4px; }
.sep { width: 1px; height: 32px; background: #d8d8de; margin: 0 4px; }

.tb {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 44px;
  padding: 2px 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  font-size: 17px;
  cursor: pointer;
  color: #333;
}
.tb span { font-size: 10px; margin-top: 1px; color: #555; }
.tb:hover { background: #ececf1; }
.tb.active { background: #dfe9ff; border-color: #7aa5ff; }
.tb.toggle.on { background: #dff5e1; border-color: #57b26a; }
.tb.danger:hover { background: #ffe3e3; }
.tb:disabled { opacity: 0.35; cursor: default; }

#zoom-label { font-size: 12px; min-width: 42px; text-align: center; color: #444; }

.swatch {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid #ccc;
  cursor: pointer;
  padding: 0;
}
.swatch.active { border-color: #333; transform: scale(1.15); }

/* ---------- mode tabs ---------- */
#map-tools .tb.active { background: #efe4ff; border-color: #9d6bff; }

/* ---------- prompt bar (mind-map mode) ---------- */
#prompt-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 34px;
  z-index: 15;
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: min(720px, calc(100vw - 24px));
  padding: 8px;
  background: rgba(255,255,255,0.95);
  border: 1px solid #d5d5dd;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.15);
}
#prompt-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px 10px;
  font: 14px "Segoe UI", system-ui, sans-serif;
  resize: none;
  outline: none;
}
#prompt-input:focus { border-color: #9d6bff; }
#mic-btn, #generate-btn {
  border: none;
  border-radius: 8px;
  padding: 0 16px;
  font-size: 15px;
  cursor: pointer;
}
#prompt-hide {
  position: absolute;
  top: -13px;
  right: -13px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid #d5d5dd;
  background: #fff;
  color: #555;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  z-index: 1;
}
#prompt-hide:hover { background: #f3f3f6; color: #111; }
#mic-btn { background: #f0f0f5; font-size: 20px; }
#mic-btn.recording { background: #ffe0e0; animation: pulse 1s infinite; }
#generate-btn { background: #6c3fd4; color: #fff; font-weight: 600; }
#generate-btn:disabled { opacity: 0.5; cursor: wait; }
@keyframes pulse { 50% { opacity: 0.6; } }

/* ---------- named maps menu ---------- */
#maps-menu {
  position: fixed;
  top: 56px;
  right: 12px;
  z-index: 25;
  width: 240px;
  background: #fff;
  border: 1px solid #d5d5dd;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.18);
  padding: 10px;
}
#maps-title { font-size: 12px; font-weight: 700; color: #555; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 8px; }
#maps-list { max-height: 240px; overflow-y: auto; }
.map-item {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 8px; border-radius: 8px; cursor: pointer;
  font-size: 14px; color: #222;
}
.map-item:hover { background: #f0f0f5; }
.map-item.current { background: #efe4ff; font-weight: 600; }
.map-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-item .del { border: none; background: none; color: #999; font-size: 15px; cursor: pointer; padding: 0 4px; }
.map-item .del:hover { color: #d33; }
#maps-empty { padding: 10px 8px; font-size: 13px; color: #888; }
#maps-save-row { display: flex; gap: 6px; margin-top: 8px; border-top: 1px solid #eee; padding-top: 8px; }
#maps-name {
  flex: 1; min-width: 0; border: 1px solid #ddd; border-radius: 8px;
  padding: 7px 9px; font: 13px "Segoe UI", system-ui, sans-serif; outline: none;
}
#maps-name:focus { border-color: #9d6bff; }
#maps-save-btn {
  border: none; border-radius: 8px; padding: 0 14px;
  background: #6c3fd4; color: #fff; font-size: 13px; font-weight: 600; cursor: pointer;
}

/* ---------- status bar ---------- */
#statusbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  padding: 4px 12px;
  font-size: 12px;
  color: #666;
  background: rgba(255,255,255,0.85);
  border-top: 1px solid #e2e2e6;
  pointer-events: none;
}

/* ---------- node text editor ---------- */
#editor {
  position: fixed;
  z-index: 20;
  border: 2px solid #7aa5ff;
  border-radius: 8px;
  padding: 4px 6px;
  font: 16px "Segoe UI", system-ui, sans-serif;
  text-align: center;
  resize: none;
  overflow: hidden;
  outline: none;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}
.hidden { display: none !important; }

/* ---------- help overlay ---------- */
#help {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}
#help-card {
  background: #fff;
  border-radius: 12px;
  padding: 22px 26px;
  max-width: 560px;
  max-height: 85vh;
  overflow: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.35);
}
#help-card h2 { font-size: 18px; margin-bottom: 12px; }
#help-card table { border-collapse: collapse; width: 100%; }
#help-card td { padding: 6px 8px; border-bottom: 1px solid #eee; font-size: 13px; vertical-align: top; }
#help-card td:first-child { white-space: nowrap; font-weight: 600; }
#help-card p { margin: 12px 0; font-size: 13px; color: #555; }
#help-close {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: #2f6bff;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}
