@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  --ice: #E07A5F;
  --light-blue: #3D405B;
  --mid-blue: #81B29A;
  --deep-blue: #F2CC8F;
  --arctic: #F4F1DE;
  --bg: #F0F6FF;
  --white: #FFFFFF;
  --surface: #FAFCFF;
  --text: #1A2A3A;
  --text-muted: #6B8299;
  --shadow-sm: 0 1px 3px rgba(13, 71, 161, 0.08);
  --shadow-md: 0 4px 16px rgba(13, 71, 161, 0.12);
  --shadow-lg: 0 8px 32px rgba(13, 71, 161, 0.16);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

::selection {
  background: var(--mid-blue);
  color: var(--white);
}

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

html, body, #root {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* Loading Screen */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 16px;
  background: var(--bg);
}

.loading-screen p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--ice);
  border-top-color: var(--mid-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-spinner.small {
  width: 24px;
  height: 24px;
  border-width: 2px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg);
}

/* Presence Bar */
.presence-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--white);
  border-bottom: 1px solid var(--ice);
  box-shadow: var(--shadow-sm);
  z-index: 100;
  min-height: 52px;
}

.presence-left {
  display: flex;
  align-items: center;
}

.board-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--arctic);
  letter-spacing: -0.02em;
}

.presence-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.presence-users {
  display: flex;
  align-items: center;
}

.presence-avatar-wrapper {
  position: relative;
  margin-left: -8px;
  transition: transform 0.2s ease;
}

.presence-avatar-wrapper:first-child {
  margin-left: 0;
}

.presence-avatar-wrapper:hover {
  transform: translateY(-2px);
  z-index: 999 !important;
}

.presence-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--white);
  box-shadow: var(--shadow-sm);
}

.presence-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background: #43A047;
  border: 2px solid var(--white);
  border-radius: 50%;
}

.presence-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--white);
  border-bottom: 1px solid var(--ice);
  z-index: 90;
  flex-wrap: wrap;
}

.toolbar-section {
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
}

.toolbar-section.tools {
  gap: 2px;
}

.toolbar-divider {
  width: 1px;
  height: 28px;
  background: var(--ice);
  margin: 0 4px;
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text-muted);
  font-family: inherit;
}

.tool-btn:hover {
  background: var(--ice);
  color: var(--deep-blue);
}

.tool-btn.active {
  background: var(--arctic);
  color: var(--white);
  box-shadow: var(--shadow-sm);
}

.tool-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.tool-label {
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.color-preview {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--ice);
}

.width-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.width-dot {
  display: block;
  border-radius: 50%;
  background: var(--arctic);
}

.toolbar-hint {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Popups */
.popup {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 8px;
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 12px;
  z-index: 200;
  animation: popIn 0.15s ease-out;
}

@keyframes popIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-4px) scale(0.96); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

.color-popup {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  min-width: 140px;
}

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

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.active {
  border-color: var(--arctic);
  box-shadow: 0 0 0 3px rgba(13, 71, 161, 0.2);
}

.width-popup {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 120px;
}

.width-option {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 2px solid transparent;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.width-option:hover {
  background: var(--ice);
}

.width-option.active {
  border-color: var(--mid-blue);
  background: var(--ice);
}

/* Whiteboard */
.whiteboard-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--surface);
}

.whiteboard-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.whiteboard-canvas.tool-draw {
  cursor: crosshair;
}

.whiteboard-canvas.tool-eraser {
  cursor: cell;
}

.whiteboard-canvas.tool-sticky,
.whiteboard-canvas.tool-text {
  cursor: pointer;
}

.elements-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.board-loading {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 50;
}

/* Sticky Notes */
.board-sticky {
  position: absolute;
  width: 160px;
  min-height: 100px;
  padding: 14px 12px 28px;
  border-radius: 4px;
  box-shadow: 2px 3px 12px rgba(0, 0, 0, 0.12);
  pointer-events: all;
  cursor: grab;
  transition: box-shadow 0.2s ease;
  animation: stickyDrop 0.3s ease-out;
  font-family: 'DM Sans', sans-serif;
}

.board-sticky:hover {
  box-shadow: 4px 6px 20px rgba(0, 0, 0, 0.18);
}

.board-sticky.dragging {
  cursor: grabbing;
  box-shadow: 6px 8px 24px rgba(0, 0, 0, 0.22);
  transform: rotate(-1deg) scale(1.03);
}

@keyframes stickyDrop {
  from { opacity: 0; transform: scale(0.8) rotate(-5deg); }
  to { opacity: 1; transform: scale(1) rotate(0deg); }
}

.sticky-text {
  font-size: 0.88rem;
  line-height: 1.4;
  word-wrap: break-word;
  color: #333;
  font-weight: 500;
}

.sticky-author {
  position: absolute;
  bottom: 6px;
  right: 8px;
  font-size: 0.65rem;
  color: rgba(0, 0, 0, 0.35);
  font-weight: 400;
}

.element-remove {
  position: absolute;
  top: 4px;
  right: 6px;
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  color: rgba(0, 0, 0, 0.3);
  line-height: 1;
  padding: 2px;
  border-radius: 4px;
  transition: all 0.15s;
  opacity: 0;
}

.board-sticky:hover .element-remove,
.board-text:hover .element-remove {
  opacity: 1;
}

.element-remove:hover {
  color: #E53935;
  background: rgba(229, 57, 53, 0.1);
}

/* Board Text */
.board-text {
  position: absolute;
  pointer-events: all;
  cursor: grab;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s;
  animation: textFadeIn 0.25s ease-out;
  white-space: nowrap;
}

.board-text:hover {
  background: rgba(13, 71, 161, 0.05);
}

.board-text.dragging {
  cursor: grabbing;
}

@keyframes textFadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 71, 161, 0.2);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  animation: overlayIn 0.2s ease-out;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 90%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  animation: modalSlide 0.25s ease-out;
}

@keyframes modalSlide {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-content h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15rem;
  color: var(--arctic);
  margin-bottom: 16px;
  font-weight: 700;
}

.sticky-color-row,
.font-size-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.sticky-color-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}

.sticky-color-btn.active {
  border-color: var(--arctic);
  box-shadow: 0 0 0 3px rgba(13, 71, 161, 0.15);
  transform: scale(1.1);
}

.sticky-color-btn:hover {
  transform: scale(1.1);
}

.sticky-input {
  width: 100%;
  height: 100px;
  border: 1px solid var(--light-blue);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  color: var(--text);
  background: var(--surface);
}

.sticky-input:focus {
  border-color: var(--mid-blue);
  box-shadow: 0 0 0 3px rgba(66, 165, 245, 0.15);
}

.text-input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--light-blue);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
  color: var(--text);
  background: var(--surface);
}

.text-input:focus {
  border-color: var(--mid-blue);
  box-shadow: 0 0 0 3px rgba(66, 165, 245, 0.15);
}

.text-preview {
  margin-top: 12px;
  padding: 12px;
  background: var(--ice);
  border-radius: var(--radius-sm);
  text-align: center;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  word-break: break-word;
}

.font-size-btn {
  flex: 1;
  padding: 8px 4px;
  border: 1px solid var(--light-blue);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s;
}

.font-size-btn:hover {
  background: var(--ice);
}

.font-size-btn.active {
  background: var(--arctic);
  color: var(--white);
  border-color: var(--arctic);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  justify-content: flex-end;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--arctic);
  color: var(--white);
}

.btn-primary:hover:not(:disabled) {
  background: var(--deep-blue);
  box-shadow: var(--shadow-sm);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--ice);
  color: var(--text-muted);
}

.btn-secondary:hover {
  background: var(--light-blue);
  color: var(--arctic);
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .presence-bar {
    padding: 8px 12px;
  }

  .board-title {
    font-size: 0.9rem;
  }

  .toolbar {
    padding: 6px 10px;
    gap: 4px;
  }

  .tool-btn {
    padding: 6px 8px;
  }

  .tool-label {
    display: none;
  }

  .toolbar-hint {
    display: none;
  }

  .toolbar-divider {
    height: 24px;
  }

  .board-sticky {
    width: 130px;
    min-height: 80px;
    padding: 10px 10px 24px;
  }

  .sticky-text {
    font-size: 0.8rem;
  }

  .modal-content {
    padding: 22px;
    margin: 0 12px;
  }

  .presence-count {
    font-size: 0.7rem;
  }

  .presence-avatar {
    width: 28px;
    height: 28px;
  }
}

@media (max-width: 380px) {
  .tool-icon {
    font-size: 1rem;
  }

  .tool-btn {
    padding: 5px 6px;
  }
}
```

<!-- WALKTHROUGH_SCRIPT:
[
  {"step": 1, "narration": "Welcome to your collaborative whiteboard! You can see who's online in the top-right corner.", "view": "default", "highlight_selector": ".presence-bar", "wait_for": "tap_to_continue"},
  {"step": 2, "narration": "Use the toolbar to switch between drawing tools. The pencil tool lets you draw freehand on the canvas.", "view": "default", "highlight_selector": ".toolbar-section.tools", "wait_for": "tap_to_continue"},
  {"step": 3, "narration": "Click and drag on the canvas to draw. Your strokes appear in real-time for everyone on the board.", "view": "default", "highlight_selector": ".whiteboard-canvas", "wait_for": "user_interaction"},
  {"step": 4, "narration": "Choose different colors and stroke widths using the Color and Size buttons in the toolbar.", "view": "default", "highlight_selector": ".color-trigger", "wait_for": "tap_to_continue"},
  {"step": 5, "narration": "Select the Sticky Note tool and click anywhere on the board to place a colorful sticky note.", "view": "default", "highlight_selector": ".tool-btn:nth-child(3)", "wait_for": "user_interaction"},
  {"step": 6, "narration": "Use the Text tool to place typed text directly on the whiteboard in different sizes.", "view": "default", "highlight_selector": ".tool-btn:nth-child(4)", "wait_for": "user_interaction"},
  {"step": 7, "narration": "Sticky notes and text can be dragged around the board. Hover to reveal the delete button.", "view": "default", "highlight_selector": ".elements-overlay", "wait_for": "tap_to_continue"},
  {"step": 8, "narration": "Share this app link with others — they'll see your drawings and notes update in real-time!", "view": "default", "highlight_selector": ".presence-users", "wait_for": "tap_to_continue"}
]
-->

.toolbar-drawing-controls {
  gap: 12px;
  align-items: center;
}

.toolbar-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-label {
  font-size: 0.85rem;
  font-weight: 600;
}

.toolbar-color-picker {
  width: 40px;
  height: 34px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.toolbar-select {
  min-width: 92px;
  height: 34px;
}

.image-upload-input {
  display: none;
}

.whiteboard-image-button {
  margin-top: 12px;
}

.whiteboard-canvas {
  position: relative;
}

.board-image {
  position: absolute;
  border: 2px solid transparent;
  cursor: pointer;
}

.board-image-selected {
  border-color: #0D47A1;
}

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

.board-element-delete {
  position: absolute;
  top: -10px;
  right: -10px;
}

.whiteboard-toolbar-hint,
.whiteboard-loading,
.whiteboard-uploading {
  margin-bottom: 8px;
}

.whiteboard {
  position: relative;
}

.whiteboard-canvas {
  width: 100%;
  height: 100%;
}

.cursor-presence {
  position: absolute;
  transform: translate(-2px, -2px);
  pointer-events: none;
  z-index: 20;
}

.cursor-pointer {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff5252;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.12);
}

.cursor-label {
  margin-top: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  color: #ffffff;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.presence-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.presence-self,
.presence-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.board-save-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.board-save-input {
  height: 34px;
  min-width: 220px;
  padding: 0 12px;
  border: 1px solid var(--light-blue);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
}

.board-save-input:focus {
  border-color: var(--mid-blue);
  box-shadow: 0 0 0 3px rgba(66, 165, 245, 0.12);
}

.board-save-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.board-save-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--ice);
}

.board-save-load,
.board-save-delete {
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.board-save-load {
  background: transparent;
  color: var(--arctic);
  font-size: 0.82rem;
  font-weight: 600;
}

.board-save-load:hover {
  text-decoration: underline;
}

.board-save-delete {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(229, 57, 53, 0.08);
  color: #E53935;
  font-size: 1rem;
  line-height: 1;
}

.board-save-delete:hover {
  background: rgba(229, 57, 53, 0.15);
}

.board-export-surface {
  width: 100%;
}

.sticky-reactions {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: all;
}

.sticky-reaction-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.sticky-reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  padding: 2px 6px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  font-size: 0.78rem;
  line-height: 1;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.sticky-reaction-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.sticky-reaction-btn.has-count {
  border-color: rgba(13, 71, 161, 0.14);
}

.sticky-reaction-emoji {
  display: inline-block;
}

.sticky-reaction-count {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--arctic);
}

.sticky-reaction-summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(0, 0, 0, 0.06);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--arctic);
  white-space: nowrap;
}

.sticky-reaction-summary-emoji {
  line-height: 1;
}

.sticky-reaction-summary-count {
  line-height: 1;
}

@media (max-width: 640px) {
  .sticky-reactions {
    left: 6px;
    right: 6px;
    bottom: 6px;
    flex-direction: column;
    align-items: flex-start;
  }

  .sticky-reaction-summary {
    align-self: flex-end;
  }
}
