:root {
  --bg: #0d0f14;
  --surface: #15181f;
  --border: #262b35;
  --text: #e7edf3;
  --text-muted: #8b93a3;
  --accent: #7c5cff;   /* ink violet, this app's signature color */
  --danger: #e2484f;

  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font-body); color: var(--text); background: var(--bg); }
.hidden { display: none !important; }
.link { color: var(--accent); text-decoration: none; font-size: 0.85rem; }
.link:hover { text-decoration: underline; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  transition: filter 0.15s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- signature element: a small cluster of drawing cursors ---------- */

.cluster {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  width: 30px;
  height: 14px;
}
.cluster i {
  display: block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  animation: bob 1.6s ease-in-out infinite;
}
.cluster i:nth-child(1) { background: #7c5cff; animation-delay: 0s; }
.cluster i:nth-child(2) { background: #ff6b6b; animation-delay: 0.2s; }
.cluster i:nth-child(3) { background: #2fd0a0; animation-delay: 0.4s; }
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
@media (prefers-reduced-motion: reduce) {
  .cluster i { animation: none; }
}

/* ---------- sign-in gate ---------- */

.gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.gate-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px;
  text-align: center;
  max-width: 340px;
}
.gate-card .cluster { margin-bottom: 14px; justify-content: center; width: auto; }
.gate-card h1 { font-size: 1.3rem; margin: 0 0 8px; }
.gate-card p { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 22px; }

/* ---------- app shell ---------- */

.app { display: flex; flex-direction: column; height: 100vh; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-name { font-weight: 700; font-size: 0.95rem; }

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

.swatches { display: flex; gap: 6px; }
.swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.swatch.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg); }

#brush-size { accent-color: var(--accent); }

/* ---------- color wheel picker ---------- */

.color-wheel-wrap { position: relative; }

.wheel-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  padding: 0;
  background: conic-gradient(
    from 90deg,
    #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000
  );
}
.wheel-btn:hover { border-color: var(--text); }

.color-popover {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 80;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 200px;
}

.wheel-canvas-wrap { position: relative; width: 160px; height: 160px; }
#wheel-canvas { border-radius: 50%; cursor: crosshair; touch-action: none; }

.wheel-dot {
  position: absolute;
  top: 0;
  left: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 1px 4px rgba(0, 0, 0, 0.5);
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: none;
}

.value-label {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.value-label input { width: 100%; accent-color: var(--accent); }

.color-popover-footer { display: flex; align-items: center; gap: 8px; width: 100%; }
.color-preview {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
}
.hex-input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 6px 8px;
}
.hex-input:focus { outline: none; border-color: var(--accent); }

.btn-ghost.active { border-color: var(--accent); color: var(--accent); background: rgba(124, 92, 255, 0.12); }

.zoom { display: flex; align-items: center; gap: 8px; }
.zoom .btn { padding: 6px 12px; line-height: 1; }
#zoom-level { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-muted); min-width: 42px; text-align: center; }

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

.presence { display: flex; gap: 6px; flex-wrap: wrap; }
.presence .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px 4px 6px;
  font-size: 0.78rem;
  font-family: var(--font-mono);
}
.presence .chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #05060a;
  min-height: 0;
  touch-action: none;
}

#board {
  position: absolute;
  top: 0;
  left: 0;
  width: 6000px;
  height: 3375px;
  background: #ffffff;
  touch-action: none;
  cursor: none;
  transform-origin: 0 0;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
#board.panning { cursor: grabbing; }
#board.fill-mode { cursor: pointer; }

#brush-cursor {
  position: fixed;
  top: 0;
  left: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 0, 0, 0.6);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.8);
  pointer-events: none;
  z-index: 60;
  transform: translate(-50%, -50%);
  display: none;
}
#brush-cursor.eraser { background: rgba(255, 255, 255, 0.5); border-style: dashed; }

#cursor-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}
.remote-cursor {
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  transform: translate(-2px, -2px);
  pointer-events: none;
}
.remote-cursor .dot {
  width: 10px;
  height: 10px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
.remote-cursor .label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: rgba(15, 17, 22, 0.85);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .tools, .right { justify-content: space-between; }
}
