* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #dcdfe4;
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #1a1c1f;
  -webkit-tap-highlight-color: transparent;
}

#board {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}
/* While the nib outline is up it *is* the cursor. */
#board.ring-on { cursor: none; }
#board.tool-pan, #board.pannable { cursor: grab; }
#board.panning { cursor: grabbing; }

/* ---------- nib outline ---------- */

#ring {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 20;
  pointer-events: none;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, .8);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .9);
  will-change: transform;
}
#ring[hidden] { display: none; }
/* A centre dot to aim the wider eraser; the marker's outline is small enough
   to aim with on its own. */
#ring i { display: none; }
#ring.is-eraser i {
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 2px;
  margin: -1px 0 0 -1px;
  border-radius: 50%;
  background: var(--ink, #111);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .85);
}

#paper { fill: #fbfbfa; }

#strokes path, #live path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- panels ---------- */

.panel {
  position: fixed;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,.14);
  user-select: none;
}
.panel[hidden] { display: none; }

.sep { width: 1px; align-self: stretch; background: rgba(0,0,0,.1); margin: 2px 2px; }

#toolbar {
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
}
.tools, .zooms { display: flex; align-items: center; gap: 6px; }

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 10px;
  color: #1a1c1f;
}

.tool {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 10px;
}
.tool:hover { background: rgba(0,0,0,.05); }
.tool.color span {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--c);
  display: block;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35);
}
.tool svg { color: #4a4f57; display: block; }
.tool[aria-pressed="true"] {
  background: rgba(0,0,0,.07);
  border-color: rgba(0,0,0,.18);
}
.tool[aria-pressed="true"] svg { color: #111; }
.tool.color[aria-pressed="true"] span { transform: scale(1.15); }
.tool.color span { transition: transform .12s ease; }

.zoom {
  min-width: 38px; height: 34px;
  padding: 0 8px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: #555;
}
.zoom:hover { background: rgba(0,0,0,.05); }
.zoom[aria-pressed="true"] {
  background: #1a1c1f;
  color: #fff;
}

#topbar {
  top: 14px;
  right: 14px;
  padding: 6px 8px 6px 12px;
  font-size: 13px;
}
#reset-timer { font-variant-numeric: tabular-nums; color: #555; }
#me-photo { width: 24px; height: 24px; border-radius: 50%; background: #ccc; }
#me-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#signout { padding: 5px 9px; color: #666; }
#signout:hover { background: rgba(0,0,0,.06); color: #111; }

#peers {
  position: fixed;
  top: 14px; left: 14px;
  z-index: 10;
  display: flex;
  user-select: none;
}
#peers[hidden] { display: none; }
#peers img {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid #fff;
  margin-right: -8px;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  background: #ccc;
}

/* ---------- cursors ---------- */

#cursors { pointer-events: none; }
#cursors text {
  font: 500 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  fill: #fff;
  dominant-baseline: middle;
}
#cursors .label { rx: 5; }

/* ---------- gate ---------- */

#gate, #loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: #eef0f3;
}
#gate[hidden], #loading[hidden] { display: none; }

#loading { background: #eef0f3; color: #777; z-index: 101; }

.gate-card {
  text-align: center;
  padding: 40px 36px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,.12);
  max-width: 380px;
}
.gate-card h1 { margin: 0 0 10px; font-size: 24px; letter-spacing: -.02em; }
.gate-card p { margin: 0 0 22px; color: #666; }

#signin {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  border: 1px solid rgba(0,0,0,.15);
  border-radius: 12px;
  background: #fff;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
#signin:hover { background: #f7f8f9; }

.error { color: #c0392b; font-size: 13px; min-height: 1em; margin: 14px 0 0 !important; }

@media (max-width: 560px) {
  #topbar #me-name { display: none; }
  #reset-timer { display: none; }
  #topbar .sep:first-of-type { display: none; }
}
