* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f2f1ed;
  color: #0B3B67;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

#toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 52px;
  height: calc(64px + env(safe-area-inset-top));
  background: #0B3B67;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: calc(10px + env(safe-area-inset-top)) 6px 10px 10px;
  z-index: 1000;
}

#topBarBg {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(64px + env(safe-area-inset-top));
  background: #0B3B67;
  z-index: 999;
}

#undoBtn {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  right: 6px;
  width: 42px;
  height: 42px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 12px;
  z-index: 1001;
  flex: none;

  font-size: 20px;
  line-height: 1;
  padding: 0;
}

button {
  flex: 1;
  height: 42px;
  border: none;
  border-radius: 12px;
  background: #C9A84C;
  color: #0B3B67;
  font-size: 15px;
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
}

button.secondary {
  background: transparent;
  color: #C9A84C;
  border: 1.5px solid #C9A84C;
}

button.active {
  background: #fff;
  color: #0B3B67;
}

#canvas {
  position: fixed;
  top: calc(64px + env(safe-area-inset-top));
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  touch-action: none;
}

#stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 5000px;
  height: 5000px;
  transform-origin: 0 0;
}

#lines {
  position: absolute;
  left: 0;
  top: 0;
  width: 5000px;
  height: 5000px;
  overflow: visible;
  z-index: 1;
}

.note {
  position: absolute;
  width: 180px;
  min-height: 96px;
  padding: 12px;
  background: #fff;
  border-radius: 16px;
  border: 2px solid transparent;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.note.selected {
  border-color: #C9A84C;
  box-shadow: 0 0 0 4px rgba(201,168,76,0.20), 0 8px 20px rgba(0,0,0,0.16);
}

.note.has-children {
  border-color: rgba(201,168,76,0.75);
}

.note.dragging {
  opacity: 0.92;
  transform: scale(1.02);
}

.note-text {
  width: 100%;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: pre-wrap;
  word-break: break-word;
  outline: none;
  font-size: 17px;
  line-height: 1.35;
  color: #000;
  -webkit-user-select: text;
  user-select: text;
}

.note-text:empty::before {
  content: "メモ";
  color: #aaa;
}

.note.editing {
  touch-action: auto;
}

.note.editing .note-text {
  background: rgba(201,168,76,0.08);
  border-radius: 8px;
}

.hint {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 20;
  background: rgba(255,255,255,0.90);
  color: #888;
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
