* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: -apple-system, Segoe UI, Arial, sans-serif; overflow: hidden; background: #1e1e20; }
/* The hidden attribute must always win over any other display rule below (.screen,
   .modal, and #toolbar all set their own `display`, which otherwise silently defeats
   [hidden] regardless of what JS sets .hidden to - hit this exact bug class before). */
[hidden] { display: none !important; }

#toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  background: #2b2b2e;
  border-bottom: 1px solid #1a1a1c;
  color: #e8e8e8;
  font-size: 13px;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-right: 12px;
  border-right: 1px solid #45454a;
}
.tool-group:last-child { border-right: none; }

button.tool, button.toggle {
  width: 32px;
  height: 32px;
  border: 1px solid #45454a;
  background: #3a3a3e;
  color: #e8e8e8;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}
button.tool:hover, button.toggle:hover { background: #4a4a50; }
button.tool.active, button.toggle.active { background: #7c3aed; border-color: #7c3aed; color: #ffffff; }

#imageToolBtn { width: 32px; height: 32px; }

.tool-group label {
  display: flex;
  align-items: center;
  gap: 4px;
}
.checkbox-label input { margin: 0; }

input[type="color"] {
  width: 28px;
  height: 24px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}
input[type="range"] { width: 90px; }

select {
  background: #3a3a3e;
  color: #e8e8e8;
  border: 1px solid #45454a;
  border-radius: 4px;
  padding: 4px;
}

#statusGroup { margin-left: auto; color: #9a9aa0; display: flex; gap: 12px; }

#canvasWrap {
  position: relative;
  width: 100%;
  height: calc(100% - 50px);
  overflow: hidden;
  /* Light grid background behind the canvas, matching the reference image: soft grey
     gridlines on an off-white ground. The canvas itself is transparent so this shows
     through everywhere nothing is drawn. */
  background-color: #f3f3f3;
  background-image:
    linear-gradient(to right, #e3e3e3 1px, transparent 1px),
    linear-gradient(to bottom, #e3e3e3 1px, transparent 1px);
  background-size: 48px 48px;
}

#board { position: absolute; top: 0; left: 0; cursor: crosshair; }

#textEditor {
  position: absolute;
  border: 1px dashed #7c3aed;
  background: rgba(255,255,255,0.85);
  resize: none;
  outline: none;
  padding: 2px;
  line-height: 1.2;
}

.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; /* above .screen too, so it can layer over the toolbar/canvas correctly */
}
.modal-box {
  background: #2b2b2e; color: #e8e8e8;
  padding: 20px; border-radius: 10px;
  display: flex; flex-direction: column; gap: 8px;
  width: 340px;
}
.modal-box input[type="text"] {
  padding: 6px; border-radius: 4px; border: 1px solid #45454a;
  background: #1e1e20; color: #e8e8e8;
}
.modal-box button {
  padding: 8px; border-radius: 6px; border: 1px solid #45454a;
  background: #3a3a3e; color: #e8e8e8; cursor: pointer;
}
.modal-box button:hover { background: #4a4a50; }
.modal-box hr { border-color: #45454a; width: 100%; }

.screen {
  position: fixed; inset: 0;
  background: #1e1e20;
  display: flex; align-items: center; justify-content: center;
  /* Without this, DOM order alone decides stacking among positioned siblings - and
     #canvasWrap (position:relative, always in the DOM, no [hidden] of its own) comes
     later in the HTML, so it was painting over this fixed overlay regardless of which
     screen was supposed to be showing. */
  z-index: 100;
}
.screen-box {
  background: #2b2b2e; color: #e8e8e8;
  padding: 28px; border-radius: 12px;
  width: 380px;
  display: flex; flex-direction: column; gap: 10px;
}
.screen-box h2 { margin: 0 0 6px 0; }
.screen-box label { font-size: 13px; color: #c3c3cc; }
.screen-box input[type="text"] {
  padding: 8px; border-radius: 6px; border: 1px solid #45454a;
  background: #1e1e20; color: #e8e8e8; font-size: 14px;
}
.screen-box .hint { font-size: 12px; color: #c3c3cc; line-height: 1.4; }
.screen-box button {
  padding: 10px; border-radius: 6px; border: 1px solid #7c3aed;
  background: #7c3aed; color: #ffffff; cursor: pointer; font-size: 14px;
}
.screen-box button:hover { background: #6d28d9; }
.screen-box .error { color: #f87171; font-size: 13px; }

.drop-zone {
  border: 2px dashed #45454a;
  border-radius: 10px;
  padding: 40px 16px;
  text-align: center;
  color: #e8e8e8;
  cursor: pointer;
  font-size: 15px;
}
.drop-zone .hint { color: #c3c3cc; font-size: 12px; margin-top: 6px; }
.drop-zone.drag-over { border-color: #7c3aed; background: rgba(124,58,237,0.08); }
.screen-box hr { border-color: #45454a; width: 100%; }

#canvasList { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }
.canvas-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px; border-radius: 6px; background: #1e1e20;
  border: 1px solid #45454a; cursor: pointer;
}
.canvas-row:hover { border-color: #7c3aed; }
.canvas-row .count { color: #c3c3cc; font-size: 12px; }

.canvas-embed {
  position: absolute;
  border: 1px solid #45454a;
  background: white;
}

.remote-cursor-label {
  position: absolute;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  color: white;
  pointer-events: none;
  transform: translate(10px, -4px);
}
