* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: #1a1a1a;
  color: #e8e8e8;
  user-select: none;
}

#toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 40px;
  padding: 0 12px;
  background: transparent;
  border: none;
  pointer-events: none;
  z-index: 100;
}

#toolbar > * {
  pointer-events: auto;
}

.dropdown {
  position: relative;
}

#btn-menu {
  padding: 5px 10px;
  font-size: 15px;
  letter-spacing: 1px;
  background: rgba(42, 42, 42, 0.75);
  color: #e8e8e8;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

#btn-menu:hover {
  background: rgba(74, 74, 74, 0.9);
}

.menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: rgba(32, 32, 32, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  padding: 4px 0;
  min-width: 160px;
  z-index: 200;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}

.menu-dropdown.hidden {
  display: none;
}

.menu-dropdown button {
  display: block;
  width: 100%;
  padding: 9px 16px;
  text-align: left;
  background: none;
  border: none;
  color: #e8e8e8;
  font-size: 13px;
  cursor: pointer;
}

.menu-dropdown button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.menu-dropdown button.danger {
  color: #ff6b6b;
}

.menu-dropdown button.danger:hover {
  background: rgba(255, 107, 107, 0.12);
}

.menu-sep {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin: 4px 0;
}

.menu-submenu-trigger {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
}

.menu-chevron {
  color: #888;
  font-size: 11px;
  margin-left: 16px;
  transition: transform 0.15s ease;
}

.menu-chevron.open {
  transform: rotate(90deg);
}

.menu-drive-panel {
  background: rgba(0, 0, 0, 0.22);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 2px 0;
}

.menu-drive-panel.hidden {
  display: none;
}

.menu-drive-panel button {
  padding-left: 28px !important;
}

.menu-note {
  padding: 4px 16px 8px;
  font-size: 11px;
  color: #999;
  line-height: 1.35;
}

.menu-check .check-mark {
  display: inline-block;
  width: 14px;
  margin-right: 6px;
  color: #4a9eff;
}

.menu-check.is-on .check-mark::before {
  content: '✓';
}

.drive-chip {
  font-size: 11px;
  color: #cfe3ff;
  background: rgba(74, 158, 255, 0.18);
  border: 1px solid rgba(74, 158, 255, 0.35);
  border-radius: 999px;
  padding: 3px 10px;
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: none;
}

.drive-chip.hidden {
  display: none;
}

.drive-chip.warn {
  color: #ffe0a6;
  background: rgba(255, 179, 71, 0.16);
  border-color: rgba(255, 179, 71, 0.4);
}

.fixed-board-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  font-size: 12px;
  color: #e8e8e8;
  background: rgba(74, 158, 255, 0.18);
  border: 1px solid rgba(74, 158, 255, 0.35);
  border-radius: 8px;
  padding: 5px 8px 5px 12px;
}

.fixed-board-banner.hidden {
  display: none;
}

.fixed-board-banner button {
  background: #3a6ea5;
  border: none;
  border-radius: 6px;
  color: #fff;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}

.fixed-board-banner button:hover {
  background: #4a9eff;
}

#fixed-board-signin.hidden {
  display: none;
}

.status {
  font-size: 12px;
  color: #bbb;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 20px;
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  width: min(480px, 100%);
  max-height: min(70vh, 560px);
  display: flex;
  flex-direction: column;
  background: #242424;
  border: 1px solid #3a3a3a;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #333;
}

.modal-header h2 {
  font-size: 15px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: #aaa;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.modal-close:hover {
  color: #fff;
}

.modal-body {
  padding: 14px 16px 16px;
  overflow: auto;
}

.modal-label {
  display: block;
  font-size: 12px;
  color: #999;
  margin-bottom: 8px;
}

.modal-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.modal-row input {
  flex: 1;
  min-width: 0;
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 6px;
  color: #e8e8e8;
  padding: 8px 10px;
  font-size: 13px;
}

.modal-row button {
  background: #3a6ea5;
  border: none;
  border-radius: 6px;
  color: #fff;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.modal-row button:hover {
  background: #4a9eff;
}

.drive-file-list {
  border: 1px solid #333;
  border-radius: 6px;
  max-height: 280px;
  overflow: auto;
}

.drive-file-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid #2e2e2e;
  color: #e8e8e8;
  padding: 10px 12px;
  cursor: pointer;
}

.drive-file-item:last-child {
  border-bottom: none;
}

.drive-file-item:hover {
  background: rgba(74, 158, 255, 0.12);
}

.drive-file-name {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
}

.drive-file-meta {
  display: block;
  font-size: 11px;
  color: #888;
}

#canvas-root {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: default;
  background: #1a1a1a;
}

#canvas-root.panning {
  cursor: grab;
}

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

#board {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

#board::before {
  content: '';
  position: absolute;
  left: -500000px;
  top: -500000px;
  width: 1000000px;
  height: 1000000px;
  background-color: #1a1a1a;
  background-image:
    radial-gradient(circle, #2a2a2a 1px, transparent 1px);
  background-size: 24px 24px;
  z-index: -1;
  pointer-events: none;
}

.board-node {
  position: absolute;
}

.image-node {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  cursor: move;
  touch-action: none;
}

.image-node img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  object-fit: fill;
}

.image-node.selected {
  outline: 2px solid #4a9eff;
  outline-offset: 2px;
}

.resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #fff;
  border: 1px solid #4a9eff;
  border-radius: 1px;
  z-index: 2;
  display: none;
}

.image-node.selected .resize-handle {
  display: block;
}

.resize-handle.nw { top: -5px; left: -5px; cursor: nwse-resize; }
.resize-handle.ne { top: -5px; right: -5px; cursor: nesw-resize; }
.resize-handle.sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.resize-handle.se { bottom: -5px; right: -5px; cursor: nwse-resize; }

.drop-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(74, 158, 255, 0.15);
  border: 3px dashed #4a9eff;
  font-size: 18px;
  color: #4a9eff;
  pointer-events: none;
  z-index: 50;
}

.drop-overlay.hidden {
  display: none;
}

.context-menu {
  position: fixed;
  background: #2a2a2a;
  border: 1px solid #4a4a4a;
  border-radius: 6px;
  padding: 4px 0;
  min-width: 140px;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.context-menu.hidden {
  display: none;
}

.context-menu button {
  display: block;
  width: 100%;
  padding: 8px 14px;
  text-align: left;
  background: none;
  border: none;
  color: #e8e8e8;
  font-size: 13px;
  cursor: pointer;
}

.context-menu button:hover {
  background: #3a3a3a;
}

.context-menu button.danger {
  color: #ff6b6b;
}

.context-menu button.danger:hover {
  background: rgba(255, 107, 107, 0.15);
}

.context-sep {
  border: none;
  border-top: 1px solid #3a3a3a;
  margin: 4px 0;
}

.shortcut-hint {
  float: right;
  font-size: 11px;
  color: #777;
  border: 1px solid #555;
  border-radius: 3px;
  padding: 0 4px;
  margin-left: 16px;
  line-height: 16px;
}

/* Text nodes — frame always hugs content, resize scales font */
.text-node {
  cursor: move;
  touch-action: none;
  width: max-content;
  height: auto;
}

.text-node.selected {
  outline: 2px solid #4a9eff;
  outline-offset: 2px;
}

.text-node.selected .resize-handle {
  display: block;
}

.text-node.editing {
  outline: 2px solid #ffb347;
  outline-offset: 2px;
}

.text-content {
  display: block;
  white-space: pre;
  outline: none;
  cursor: inherit;
  padding: 4px 6px;
  min-width: 20px;
  min-height: 1em;
  line-height: 1.2;
}

.text-node.editing .text-content {
  cursor: text;
}

/* Marquee selection rectangle */
#marquee {
  position: absolute;
  display: none;
  border: 1px dashed #4a9eff;
  background: rgba(74, 158, 255, 0.08);
  pointer-events: none;
  z-index: 10;
}
