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

body {
  overflow: hidden;
  background: #fff;
  font-family: sans-serif;
}

/* Remote cursors */
#cursors {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.cursor-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: flex-start;
  gap: 5px;
  transform-origin: top left;
}

.cursor-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.cursor-label {
  font-size: 0.72rem;
  font-family: sans-serif;
  font-weight: 600;
  background: rgba(255,255,255,0.85);
  padding: 1px 5px;
  border-radius: 4px;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transform: translateY(-4px);
}

body.dark .cursor-label {
  background: rgba(30,30,40,0.85);
  color: #f0f0f0;
}

/* Material Symbols */
.material-symbols-outlined {
  font-size: 18px;
  vertical-align: middle;
  user-select: none;
}

/* Join overlay */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#overlay.hidden {
  display: none;
}

#join-modal {
  background: #fff;
  border-radius: 12px;
  padding: 2rem;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

#join-modal h2 {
  font-size: 1.4rem;
  color: #222;
}

#join-modal p {
  font-size: 0.9rem;
  color: #666;
}

#join-row {
  display: flex;
  gap: 8px;
}

#join-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
}

#join-input:focus {
  border-color: #3498db;
}

#join-submit {
  padding: 8px 16px;
  background: #3498db;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}

#join-submit:hover {
  background: #2980b9;
}

/* Canvas */
canvas {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  cursor: crosshair;
}

#controls-group {
  position: fixed;
  top: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 20;
}

#help-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid #ccc;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(6px);
  font-size: 0.85rem;
  font-weight: bold;
  color: #666;
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

#controls-tooltip {
  position: absolute;
  top: 0;
  right: calc(100% + 8px);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(6px);
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.75rem;
  color: #555;
  white-space: nowrap;
  line-height: 1.8;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#help-btn:hover #controls-tooltip {
  opacity: 1;
}

#darkmode-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid #ccc;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(6px);
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
}

#status {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  font-size: 0.75rem;
  background: rgba(255,255,255,0.8);
  padding: 2px 8px;
  border-radius: 4px;
  z-index: 10;
}

/* Dark mode */
body.dark {
  background: #1a1a1e;
}

body.dark #darkmode-toggle {
  background: rgba(40,40,50,0.85);
  border-color: #444;
  color: #f0f0f0;
}

body.dark #toolbar {
  background: rgba(30,30,40,0.85);
}

body.dark #eraser {
  background: #2a2a34;
  border-color: #444;
  color: #ccc;
}

body.dark #eraser.active {
  background: #3a3a48;
  border-color: #aaa;
}

body.dark #status {
  background: rgba(30,30,40,0.8);
  color: #aaa;
}

body.dark #toast {
  background: rgba(30,30,40,0.9);
  border-color: #444;
  color: #ccc;
}

body.dark #user-count {
  color: #aaa;
}

body.dark #chat-panel {
  background: rgba(25,25,35,0.97);
  border-color: #444;
}

body.dark #chat-tab {
  background: rgba(25,25,35,0.97);
  border-color: #444;
  border-right-color: #1a1a26;
}

body.dark #chat-tab .material-symbols-outlined {
  color: #f0f0f0;
}

body.dark #help-btn {
  background: rgba(40,40,50,0.85);
  border-color: #444;
  color: #aaa;
}

body.dark #controls-tooltip {
  background: rgba(30,30,40,0.92);
  border-color: #444;
  color: #aaa;
}

#chat-tab.unread {
  background: #e74c3c;
  border-color: #e74c3c;
  border-right-color: white;
  width: 60px;
  height: 66px;
  left: -60px;
}

#chat-tab.unread .material-symbols-outlined {
  color: white;
  font-size: 27px;
}

body.dark #chat-tab.unread {
  border-right-color: #1a1a26;
}

body.dark #chat-messages {
  color: #ccc;
}

body.dark .chat-message.system {
  color: #666;
}

body.dark #chat-input,
body.dark #join-input,
body.dark #username-input {
  background: #2a2a34;
  border-color: #444;
  color: #f0f0f0;
}

body.dark #join-modal {
  background: #1e1e28;
  color: #f0f0f0;
}

body.dark #join-modal p {
  color: #aaa;
}

body.dark #chat-input-row {
  border-top-color: #333;
}

#user-count {
  font-size: 0.8rem;
  color: #777;
  white-space: nowrap;
  padding-left: 4px;
}

#toast {
  position: fixed;
  top: 1rem;
  left: 1rem;
  font-size: 0.8rem;
  background: rgba(255,255,255,0.9);
  border: 1px solid #ddd;
  padding: 6px 12px;
  border-radius: 6px;
  z-index: 20;
  color: #555;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

#toast.visible {
  opacity: 1;
}

#toolbar {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  align-items: center;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(6px);
  padding: 8px 12px;
  border-radius: 999px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  z-index: 10;
}

.swatch {
  width: 28px;
  height: 28px;
  border: 3px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: border-color 0.15s;
}

.swatch.active {
  border-color: #333;
}

#eraser {
  padding: 4px 12px;
  height: 28px;
  border: 2px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 0.8rem;
}

#eraser.active {
  border-color: #333;
  background: #eee;
}


#thickness {
  width: 80px;
  cursor: pointer;
  accent-color: #3498db;
}

/* Chat panel */
#chat-panel {
  position: fixed;
  top: 25%;
  right: 0;
  width: 320px;
  height: 75vh;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid #ccc;
  border-right: none;
  border-radius: 8px 0 0 8px;
  display: flex;
  flex-direction: column;
  z-index: 15;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  overflow: visible;
}

#chat-panel.open {
  transform: translateX(0);
}

#chat-tab {
  position: absolute;
  left: -40px;
  top: 2rem;
  width: 40px;
  height: 44px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid #ccc;
  border-right-color: white;
  border-radius: 8px 0 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: width 0.2s ease, height 0.2s ease, left 0.2s ease, background 0.2s ease;
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-message {
  font-size: 0.85rem;
  line-height: 1.4;
  word-break: break-word;
}

.chat-message .author {
  font-weight: bold;
  margin-right: 4px;
}

.chat-message.system {
  color: #999;
  font-style: italic;
  font-size: 0.8rem;
}

#chat-input-row {
  display: flex;
  padding: 1rem;
  border-top: 1px solid #eee;
  gap: 6px;
}

#chat-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.85rem;
  outline: none;
}

#chat-input:focus {
  border-color: #3498db;
}

#chat-send {
  padding: 6px 12px;
  background: #3498db;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
}

#chat-send:hover {
  background: #2980b9;
}
