:root {
  --bg: #0b0f19;
  --panel: #111827;
  --panel-2: #1f2937;
  --border: #273244;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --danger: #ef4444;
  --ok: #22c55e;
  --warn: #f59e0b;
  --board: #0f172a;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------------- top bar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #131a2b, var(--panel));
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  z-index: 2;
}

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

.brand-logo {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
  position: relative;
}
.brand-logo::after {
  content: "";
  position: absolute;
  inset: 7px 5px;
  border: 2.5px solid #fff;
  border-color: #fff transparent transparent transparent;
  border-radius: 50% 50% 0 0;
}

.brand-name {
  font-weight: 650;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
}
.status--connected .status-dot { background: var(--ok); animation: pulse 2s infinite; }
.status--connecting .status-dot { background: var(--warn); }
.status--offline .status-dot { background: var(--danger); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* ------------------------------------------------------------------ tools */

.tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.swatches {
  display: flex;
  gap: 5px;
}

.swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease, border-color 0.12s ease;
  outline: none;
}
.swatch:hover { transform: scale(1.12); }
.swatch.is-active {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--panel-2), 0 0 0 3px rgba(255, 255, 255, 0.35);
}
.swatch:focus-visible { border-color: var(--accent); }

.color-picker {
  position: relative;
  width: 26px;
  height: 26px;
  margin-left: 4px;
  cursor: pointer;
}
.color-picker input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.color-preview {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: conic-gradient(#f43f5e, #f59e0b, #22c55e, #06b6d4, #6366f1, #f43f5e);
  pointer-events: none;
  position: relative;
}
.color-preview::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--picker-color, #fff);
  border: 1px solid rgba(0, 0, 0, 0.3);
}

.tool-group--size { min-width: 190px; }

.brush-dot-wrap {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.brush-dot {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  transition: width 0.08s ease, height 0.08s ease;
  max-width: 30px;
  max-height: 30px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 110px;
  height: 4px;
  background: #374151;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
}

.size-label {
  min-width: 22px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: rgba(255, 255, 255, 0.06); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.is-active {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.6);
  color: #c7d2fe;
}
.btn--danger { color: #fca5a5; }
.btn--danger:hover { background: rgba(239, 68, 68, 0.15); border-color: rgba(239, 68, 68, 0.4); }

/* --------------------------------------------------------------- presence */

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

.avatars {
  display: flex;
  align-items: center;
}
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--panel);
  margin-left: -8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #0b0f19;
  text-transform: uppercase;
  cursor: default;
  position: relative;
  transition: transform 0.12s ease;
}
.avatar:first-child { margin-left: 0; }
.avatar:hover { transform: translateY(-2px); z-index: 1; }
.avatar--you { box-shadow: 0 0 0 2px var(--accent); }
.avatar--more { background: var(--panel-2); color: var(--muted); }

.user-count {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.name-field input {
  width: 130px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.12s ease;
}
.name-field input:focus { border-color: var(--accent); }
.name-field input::placeholder { color: #6b7280; }

/* -------------------------------------------------------------- workspace */

.workspace {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.045) 1px, transparent 0) 0 0 / 24px 24px,
    var(--bg);
}

.stage {
  position: relative;
  background: var(--board);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  touch-action: none;
}

.board {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.board.is-erasing { cursor: cell; }

/* ------------------------------------------------------------------ toast */

.toast {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.92);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}
.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .topbar { padding: 8px 10px; gap: 8px; }
  .brand-name { display: none; }
  .btn span { display: none; }
  .btn { padding: 6px; }
  .tool-group--size { min-width: 0; }
  input[type="range"] { width: 80px; }
  .name-field input { width: 96px; }
  .workspace { padding: 8px; }
}
