/* The board: a whiteboard you can scroll forever, with floating tools. */
.board-page { height: 100dvh; overflow: hidden; overscroll-behavior: none; }

.canvas {
  position: fixed; inset: 0; overflow: hidden; touch-action: none; outline: none; cursor: default;
  background-color: var(--board);
  /* faint ghosting: what's left on a whiteboard that has been wiped a hundred times */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='640' height='640'%3E%3Cg fill='none' stroke='%2317191e' stroke-linecap='round' stroke-opacity='.02' stroke-width='9'%3E%3Cpath d='M60 120c60-30 140-40 210-10'/%3E%3Cpath d='M420 80c30 40 90 60 150 40'/%3E%3Cpath d='M90 420c50 60 150 70 230 20' stroke-width='14'/%3E%3Cpath d='M460 380c-20 70 30 140 120 150'/%3E%3Cpath d='M250 260c40-20 90-10 120 30'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 640px 640px;
}
.canvas.tool-pen, .canvas.tool-marker, .canvas.tool-hl { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Ccircle cx='12' cy='12' r='3' fill='%2317191e' stroke='white' stroke-width='1.5'/%3E%3C/svg%3E") 12 12, crosshair; }
.canvas.tool-eraser { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28'%3E%3Ccircle cx='14' cy='14' r='10' fill='white' fill-opacity='.6' stroke='%2317191e' stroke-width='1.5'/%3E%3C/svg%3E") 14 14, cell; }
.canvas.tool-arrow, .canvas.tool-note, .canvas.tool-text, .canvas.tool-rect, .canvas.tool-ellipse, .canvas.tool-image { cursor: crosshair; }
.canvas.tool-hand, .canvas.space { cursor: grab; }
.canvas.panning { cursor: grabbing; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.live-ink { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; z-index: 100000; }

/* ---------------------------------------------------------------- items */
.item {
  position: absolute; left: 0; top: 0; display: flex; flex-direction: column;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.item .text {
  flex: 1; margin: 0; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere;
  font: 500 var(--fs, 20px)/1.28 var(--font-hand); font-variation-settings: "INFM" 55, "BNCE" 18; letter-spacing: -0.005em;
  color: var(--ink);
}
.item textarea {
  flex: 1; width: 100%; margin: 0; border: 0; resize: none; outline: none; background: transparent; overflow: auto;
  font: 500 var(--fs, 20px)/1.28 var(--font-hand); font-variation-settings: "INFM" 55, "BNCE" 18; letter-spacing: -0.005em;
  color: inherit; caret-color: var(--red);
}

.item.note {
  background: var(--fill, var(--sun)); border-radius: 4px 4px 4px 4px;
  box-shadow: 0 1px 1px rgba(23,25,30,.06), 0 10px 22px -10px rgba(23,25,30,.28);
}
.item.note::after {
  /* the lifted corner of a real sticky note */
  content: ""; position: absolute; right: 0; bottom: 0; width: 26px; height: 26px; pointer-events: none;
  background: linear-gradient(135deg, transparent 50%, rgba(23,25,30,.07) 50%);
  border-radius: 0 0 4px 0;
}
.item.note .text, .item.note textarea { padding: 16px 16px 20px; }
.item.rect, .item.ellipse {
  background: var(--fill, var(--sky)); border: 2.5px solid var(--ink);
}
.item.rect { border-radius: 14px; }
.item.ellipse { border-radius: 50%; }
.item.rect .text, .item.ellipse .text, .item.rect textarea, .item.ellipse textarea {
  display: grid; place-items: center; text-align: center; padding: 14px;
}
.item.ellipse .text, .item.ellipse textarea { padding: 20% 16%; }
.item.rect textarea, .item.ellipse textarea { display: block; padding-top: 28%; }
.item.text .text, .item.text textarea { padding: 4px 6px; color: var(--fill, var(--ink)); font-size: var(--fs, 26px); font-weight: 600; font-variation-settings: "INFM" 70, "BNCE" 22; }
.item.text .text:empty::after { content: "Text"; opacity: .35; }
.item.note .text:empty::after, .item.rect .text:empty::after, .item.ellipse .text:empty::after { content: "Write something"; opacity: .38; font-weight: 400; }

.item.image { border-radius: 8px; background: var(--board-2); overflow: visible; box-shadow: 0 1px 2px rgba(23,25,30,.08), 0 14px 30px -14px rgba(23,25,30,.35); }
.item.image img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; opacity: 0; transition: opacity 260ms ease; pointer-events: none; }
.item.image.loaded img, .item.image.uploading img { opacity: 1; }
.item.image.pending, .item.image.uploading { background: linear-gradient(100deg, var(--board-2) 30%, #fff 50%, var(--board-2) 70%) 0 0 / 300% 100%; animation: shimmer 1.4s linear infinite; }
.item.image.uploading img { opacity: .55; filter: saturate(.6); }
/* videos: a dark frame until the first frame loads, a play button that only plays it for you */
.item.video { border-radius: 10px; background: #17191e; overflow: visible; box-shadow: 0 1px 2px rgba(23,25,30,.1), 0 16px 34px -14px rgba(23,25,30,.45); }
.item.video video { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; display: block; pointer-events: none; opacity: 0; transition: opacity 260ms ease; }
.item.video.loaded video, .item.video.uploading video { opacity: 1; }
.item.video .play {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border: 0; border-radius: 50%;
  display: grid; place-items: center; color: #fff; background: rgba(23,25,30,.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  pointer-events: auto; cursor: pointer; transition: transform 160ms var(--ease-out), opacity 200ms ease, background-color 160ms ease;
}
.item.video .play svg { width: 24px; height: 24px; }
.item.video .play:active { transform: scale(0.92); }
@media (hover: hover) { .item.video .play:hover { background: rgba(23,25,30,.72); } }
.item.video.playing .play { opacity: 0; }
@media (hover: hover) { .item.video.playing:hover .play { opacity: 1; } }
.item.video .dur { position: absolute; right: 10px; bottom: 10px; padding: 2px 7px; border-radius: 6px; background: rgba(23,25,30,.6); color: #fff; font: 600 0.75rem/1.4 var(--font-data); font-variant-numeric: tabular-nums; pointer-events: none; }
.item.video .dur:empty { display: none; }
.item.video.uploading::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 12px; height: 4px; border-radius: 4px;
  background: linear-gradient(90deg, #fff calc(var(--p, 0) * 100%), rgba(255,255,255,.25) 0);
}
.item.video.uploading .play, .item.video.uploading .dur { display: none; }
.item.video.pending:not(.uploading) { animation: shimmer 1.4s linear infinite; background: linear-gradient(100deg, #17191e 30%, #2a2e36 50%, #17191e 70%) 0 0 / 300% 100%; }
@keyframes shimmer { to { background-position: -300% 0; } }

.item.ink, .item.arrow { pointer-events: none; }
.item.ink svg, .item.arrow svg { width: 100%; height: 100%; overflow: visible; }
.item.ink.hl svg { mix-blend-mode: multiply; }
.item .hit { fill: none; stroke: transparent; stroke-width: 18px; vector-effect: non-scaling-stroke; stroke-linecap: round; pointer-events: stroke; cursor: default; }
.item.ink.selected, .item.arrow.selected { outline: 1.5px dashed var(--select); outline-offset: 4px; border-radius: 6px; }

.item.selected:not(.ink):not(.arrow) { outline: 2px solid var(--select); outline-offset: 5px; }
.item.dragging { cursor: grabbing; }
.item.dragging.note { box-shadow: 0 2px 4px rgba(23,25,30,.08), 0 22px 40px -14px rgba(23,25,30,.4); }
.item { transform-origin: 50% 50%; }
.item .grip {
  position: absolute; width: 14px; height: 14px; border-radius: 4px;
  background: #fff; border: 2px solid var(--select); display: none; pointer-events: auto; z-index: 2;
  box-shadow: 0 1px 3px rgba(23,25,30,.18);
}
.item .grip[data-c="nw"] { left: -12px; top: -12px; cursor: nwse-resize; }
.item .grip[data-c="ne"] { right: -12px; top: -12px; cursor: nesw-resize; }
.item .grip[data-c="sw"] { left: -12px; bottom: -12px; cursor: nesw-resize; }
.item .grip[data-c="se"] { right: -12px; bottom: -12px; cursor: nwse-resize; }
/* the turning handle: a knob on a short stem above the item */
.item .rot {
  position: absolute; left: 50%; top: -42px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%;
  background: #fff; border: 2px solid var(--select); display: none; pointer-events: auto; z-index: 2; cursor: grab;
  box-shadow: 0 1px 3px rgba(23,25,30,.18); transition: transform 140ms var(--ease-out);
}
.item .rot::after { content: ""; position: absolute; left: 50%; top: 100%; width: 2px; height: 18px; margin: 2px 0 0 -1px; background: var(--select); pointer-events: none; }
@media (hover: hover) { .item .rot:hover, .item .grip:hover { transform: scale(1.18); } }
.item .grip { transition: transform 140ms var(--ease-out); }
.canvas.rotating, .canvas.rotating * { cursor: grabbing !important; }
.item.selected .grip, .item.selected .rot { display: block; }
@media (pointer: coarse) {
  /* bigger targets for fingers, drawn the same size */
  .item .grip::before, .item .rot::before { content: ""; position: absolute; inset: -12px; }
}
.item.arrive { animation: arrive 360ms var(--ease-out); }
.item.ink.arrive, .item.arrow.arrive { animation: ink-arrive 420ms var(--ease-out); }
@keyframes arrive { from { opacity: 0; scale: 0.94; } }
@keyframes ink-arrive { from { opacity: 0; filter: blur(3px); } }
.item.leaving { opacity: 0; scale: 0.96; transition: opacity 150ms ease, scale 150ms ease; }
.item.erasing { opacity: .25; transition: opacity 90ms ease; }

/* remote cursors */
.cursors { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 30; }
.cursor { position: absolute; left: 0; top: 0; transition: transform 110ms linear, opacity 200ms ease; }
.cursor svg { width: 20px; height: 20px; display: block; filter: drop-shadow(0 1px 1px rgba(0,0,0,.2)); }
.cursor span {
  position: absolute; left: 15px; top: 17px; padding: 3px 8px; border-radius: 8px;
  font: 600 0.75rem/1.3 var(--font-ui); white-space: nowrap; color: #fff;
}

.empty { position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%); width: min(420px, calc(100vw - 48px)); text-align: center; color: var(--ink-3); pointer-events: none; animation: fade 400ms ease; }
.empty-title { font: 700 1.75rem/1.15 var(--font-hand); font-variation-settings: "INFM" 60, "BNCE" 20; color: var(--ink); margin: 0 0 8px; }
.empty p { margin: 0; }
.drop { position: absolute; inset: 14px; border-radius: 28px; display: grid; place-items: center; background: rgba(31, 79, 214, .06); box-shadow: inset 0 0 0 2.5px var(--blue); z-index: 40; pointer-events: none; animation: fade 140ms ease; }
.drop p { font: 700 1.5rem/1 var(--font-hand); color: var(--blue); }

/* ---------------------------------------------------------------- floating bars */
.bar { position: fixed; z-index: 50; display: flex; align-items: center; gap: 8px; }
.top-left { top: max(14px, env(safe-area-inset-top)); left: 14px; padding: 6px 10px 6px 6px; background: #fff; border-radius: 18px; box-shadow: var(--float); max-width: calc(100vw - 28px); }
.top-right { top: max(14px, env(safe-area-inset-top)); right: 14px; }
.bottom-left { bottom: max(14px, env(safe-area-inset-bottom)); left: 14px; gap: 8px; }
.bottom-right { bottom: max(18px, env(safe-area-inset-bottom)); right: 14px; gap: 10px; }
.group { display: flex; align-items: center; padding: 4px; background: #fff; border-radius: 16px; box-shadow: var(--float); }
.mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; color: var(--ink); transition: background-color 140ms ease; }
.mark svg { width: 28px; height: 28px; }
@media (hover: hover) { .mark:hover { background: var(--board-2); } }
.title {
  width: auto; min-width: 6ch; max-width: 34ch; field-sizing: content; height: 36px; padding: 0 8px; border: 0; border-radius: 10px; background: transparent;
  font: 650 1rem/1 var(--font-ui); letter-spacing: -0.01em; color: var(--ink); text-overflow: ellipsis;
  transition: background-color 140ms ease;
}
.title:hover:not(:disabled) { background: var(--board-2); }
.title:focus { outline: none; background: var(--board-2); box-shadow: 0 0 0 2px var(--focus); }
.title:disabled { color: var(--ink-3); }
.status { display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 10px; border-radius: 999px; background: var(--board-2); font-size: 0.8125rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.status[data-s="live"] i { background: var(--live); box-shadow: 0 0 0 3px rgba(19, 138, 79, .18); }
.status[data-s="connecting"] i, .status[data-s="loading"] i { background: var(--orange); animation: blink 1.1s ease-in-out infinite; }
.status[data-s="offline"] i { background: var(--red); }
.status[data-s="paused"] { background: var(--ink); color: #fff; }
.status[data-s="paused"] i { background: #fff; }
@keyframes blink { 50% { opacity: .3; } }

.top-right > .icon-btn, .top-right .account-btn { background: #fff; box-shadow: var(--float); }
.top-right .icon-btn[aria-pressed="true"] { background: var(--ink); color: #fff; }
.top-right .btn.ghost { --bg: #fff; box-shadow: var(--float); min-height: 40px; }
.top-right .btn.primary { min-height: 40px; box-shadow: var(--float); }
.peers { display: flex; align-items: center; padding-right: 4px; }
.peer {
  width: 34px; height: 34px; margin-left: -8px; border-radius: 50%; display: grid; place-items: center;
  font: 700 0.75rem/1 var(--font-ui); color: #fff; box-shadow: 0 0 0 2.5px var(--board);
  animation: peer-in 340ms var(--ease-out);
}
.peer.me { box-shadow: 0 0 0 2.5px var(--board), 0 0 0 4px var(--ink); }
@keyframes peer-in { from { transform: scale(0.6); opacity: 0; } }

.zoom-label { min-width: 54px; height: 40px; border: 0; background: transparent; border-radius: 10px; color: var(--ink-2); }
@media (hover: hover) { .zoom-label:hover { background: var(--board-2); } }
.sync { color: var(--ink-3); font-size: 0.75rem; }

/* ---------------------------------------------------------------- tool dock */
.dock {
  position: fixed; z-index: 60; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 2px; padding: 6px; background: #fff; border-radius: 20px; box-shadow: var(--float-lg);
}
.dock .sep { width: 1px; height: 24px; margin: 0 6px; background: var(--board-3); }
.dock .icon-btn { width: 44px; height: 44px; border-radius: 14px; position: relative; z-index: 1; transition: color 160ms ease, transform 120ms var(--ease-out); }
.dock .icon-btn[aria-pressed="true"] { background: transparent; color: #fff; }
.dock-pill {
  position: absolute; z-index: 0; top: 0; left: 0; width: 44px; height: 44px; border-radius: 14px; background: var(--ink);
  transition: transform 260ms var(--ease-out), opacity 160ms ease; pointer-events: none;
}
.dock .icon-btn .swatch-dot { position: absolute; right: 7px; bottom: 7px; width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 0 1.5px #fff; }
.dock .tip {
  position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%) translateY(4px); padding: 5px 9px; border-radius: 8px;
  background: var(--ink); color: #fff; font-size: 0.75rem; font-weight: 600; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity 120ms ease, transform 160ms var(--ease-out);
}
.dock .tip kbd { font: 600 0.6875rem var(--font-ui); opacity: .6; margin-left: 6px; }
@media (hover: hover) and (pointer: fine) {
  .dock .icon-btn:hover .tip { opacity: 1; transform: translateX(-50%); transition-delay: 450ms; }
  .dock.tips-warm .icon-btn:hover .tip { transition-delay: 0ms; }
}

.options {
  position: fixed; z-index: 59; left: 50%; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 70px); transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px; padding: 6px 8px; background: #fff; border-radius: 16px; box-shadow: var(--float);
  animation: rise 200ms var(--ease-out);
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 6px); } }
.sizes { display: flex; gap: 2px; padding: 2px; border-radius: 12px; background: var(--board-2); }
.size-btn {
  min-width: 34px; height: 30px; padding: 0 8px; border: 0; border-radius: 10px; background: transparent; color: var(--ink-2);
  font: 650 0.8125rem/1 var(--font-ui); letter-spacing: 0.01em; cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, transform 120ms var(--ease-out);
}
.size-btn span { display: inline-block; font-family: var(--font-hand); font-weight: 700; }
@media (hover: hover) and (pointer: fine) { .size-btn:hover { color: var(--ink); background: rgba(23,25,30,.06); } }
.size-btn:active { transform: scale(0.94); }
.size-btn[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(23,25,30,.12), 0 2px 8px -2px rgba(23,25,30,.16); }
.size-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.options .sep { width: 1px; height: 22px; margin: 0 4px; background: var(--board-3); }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 0; padding: 0; display: grid; place-items: center; background: transparent; transition: transform 140ms var(--ease-out); }
.swatch i { width: 22px; height: 22px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1.5px rgba(23,25,30,.12); transition: transform 160ms var(--ease-out); }
.swatch[aria-pressed="true"] i { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); transform: scale(0.86); }
.swatch:active i { transform: scale(0.8); }
.options .icon-btn { width: 36px; height: 36px; }

/* ---------------------------------------------------------------- fatal */
.fatal { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; background: var(--board); padding: 24px; text-align: center; }
.fatal h2 { font: 700 2.25rem/1.1 var(--font-hand); font-variation-settings: "INFM" 50; letter-spacing: -0.02em; margin: 0 0 10px; }
.fatal p { color: var(--ink-3); max-width: 420px; margin: 0 auto 22px; }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 760px) {
  .top-left { padding-right: 6px; }
  .title { max-width: 38vw; font-size: 0.9375rem; }
  .status span { display: none; }
  .status { padding: 0 9px; }
  .peers .peer:nth-child(n+3) { display: none; }
  #shareBtn span { display: none; }
  #shareBtn { padding: 0 11px; }
  .top-right .account-btn span { display: none; }
  .top-right .account-btn { padding: 0 11px; }
  .dock { bottom: max(10px, env(safe-area-inset-bottom)); max-width: calc(100vw - 16px); overflow-x: auto; scrollbar-width: none; padding: 5px; }
  .dock .icon-btn { width: 42px; height: 42px; }
  .dock .sep { margin: 0 3px; }
}
@media (max-width: 520px) {
  /* two fingers pan on touch, so the hand tool gives its room to the rest */
  .dock [data-tool="hand"] { display: none; }
  .dock { gap: 0; }
  .dock .icon-btn { width: 31px; height: 40px; border-radius: 12px; }
  .dock-pill { border-radius: 12px; }
  .dock .icon-btn .swatch-dot { right: 4px; bottom: 6px; }
  .options { bottom: calc(max(10px, env(safe-area-inset-bottom)) + 66px); max-width: calc(100vw - 16px); overflow-x: auto; }
  .bottom-left { bottom: auto; top: calc(max(14px, env(safe-area-inset-top)) + 60px); left: 14px; }
  .bottom-left .group:last-child { display: none; }
  .bottom-right { bottom: auto; top: calc(max(14px, env(safe-area-inset-top)) + 64px); right: 14px; }
  .sync { display: none; }
  .toasts { bottom: calc(env(safe-area-inset-bottom, 0px) + 140px); }
}
@media (max-width: 420px) {
  .top-right { gap: 6px; }
  .peers { display: none; }
}
