/* Geist, the typeface of the logo, for the whole app (SIL Open Font License, see fonts/Geist-LICENSE.txt). */
@font-face {
  font-family: "Geist";
  src: url("/fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f7f7f5;
  --dot: #d6d6d0;
  --gridline: #ebebe6;
  --fg: #1d1d1f;
  --muted: #6e6e73; /* secondary label, 4.5:1 or better on every surface */
  --surface: rgba(255, 255, 255, 0.76); /* translucent material, blurred behind */
  --panel: #ffffff;
  --card: #ffffff;
  --field: rgba(118, 118, 128, 0.12);
  --fill: rgba(120, 120, 128, 0.2);
  --border: rgba(60, 60, 67, 0.13);
  --hover: rgba(118, 118, 128, 0.1);
  --active: rgba(118, 118, 128, 0.18);
  --accent: #007aff;
  --accent-soft: rgba(0, 122, 255, 0.2);
  --danger: #ff3b30;
  --important: #ff9500;
  --on: #34c759;
  --grouped: #f2f2f7; /* settings: gray page, white groups */
  --grouped-card: #ffffff;
  --thumb: #ffffff; /* the selected part of a segmented control */
  --edge: #9b9b95;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.14);
  --note-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.05);
  --note-shadow-lift: 0 4px 10px rgba(0, 0, 0, 0.08), 0 16px 32px rgba(0, 0, 0, 0.1);
  --note-fg: #2a2926;
  --inv: 1;

  /* Corner radii, small to large. Inner corners nest in outer ones (outer = inner + padding).
     Where the browser can draw squircles (continuous corners) they get a larger radius,
     because a squircle of the same radius looks tighter than a circular arc. */
  --r-xs: 4px;
  --r-sm: 7px;
  --r-md: 10px;
  --r-card: 12px;
  --r-lg: 14px;
  --r-xl: 20px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1); /* fast start, long settle, like system sheets */
  --tap: 36px; /* smallest button: 44px on touch screens */

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  color-scheme: light;
  --font: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

:root[data-theme="dark"] {
  --bg: #151515;
  --dot: #2e2e2e;
  --gridline: #1f1f1f;
  --fg: #f5f5f7;
  --muted: #98989d;
  --surface: rgba(30, 30, 32, 0.74);
  --panel: #1c1c1e;
  --card: #232325;
  --field: rgba(118, 118, 128, 0.24);
  --fill: rgba(120, 120, 128, 0.36);
  --border: rgba(84, 84, 88, 0.45);
  --hover: rgba(118, 118, 128, 0.18);
  --active: rgba(118, 118, 128, 0.28);
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.3);
  --danger: #ff453a;
  --important: #ff9f0a;
  --on: #30d158;
  --grouped: #1c1c1e;
  --grouped-card: #2c2c2e;
  --thumb: #636366;
  --edge: #6c6c68;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --note-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
  --note-shadow-lift: 0 4px 10px rgba(0, 0, 0, 0.4), 0 16px 32px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

/* Continuous (squircle) corners where supported; elsewhere the same shapes with circular corners. */
@supports (corner-shape: squircle) {
  :root { --r-xs: 6px; --r-sm: 10px; --r-md: 15px; --r-card: 18px; --r-lg: 20px; --r-xl: 30px; }
  *, *::before, *::after { corner-shape: squircle; }
  /* Circles and capsules stay what they are. */
  .avatar, .people span, .swatch-dot, .dot-btn i, .size-btn i, .connect-handle, .shape-handle.ctl,
  .shape-handle.rot, .shape-handle.rot::before, .rot-knob, .eraser-cursor, .swatch-del, .add-color,
  .author-tag i, .author-info i, .toggle input, .toggle input::after, .board-card .tag,
  .card-pill, .reaction, .comment-send, .item-tools .text-btn.unread::after,
  .who-avatar, .member-color, .member-swatch, .member-plus, .call-avatar, .call-count,
  .player .play, .player .wave i, .rec-dot, .rec-stop, .rec-meter i, .comment-mic, .card-tags span, .new-btn { corner-shape: round; }
}
@media (pointer: coarse) { :root { --tap: 44px; } }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  overscroll-behavior: none;
}

body.on-board {
  position: fixed;
  inset: 0;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.canvas, .topbar, .dock-wrap, .item-tools, .menu, .toast { touch-action: none; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

input { font: inherit; color: inherit; }

button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 1px;
}

/* ---------- Home ---------- */

.home {
  min-height: 100%;
  display: flex;
  justify-content: center;
  padding: calc(12vh + var(--safe-top)) 24px calc(56px + var(--safe-bottom));
  background: var(--bg);
}

.home-inner { width: 100%; max-width: 1040px; display: flex; flex-direction: column; gap: 56px; }
.home-hero { display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; }
.home-title { width: 100%; margin: 0; line-height: 0; }
.tagline {
  margin: 0; max-width: 26em; color: var(--muted);
  font-size: 17px; line-height: 1.45; font-weight: 400; letter-spacing: -0.005em; text-wrap: balance;
}
.home-hero .primary { margin-top: 18px; }

/* The name above the tagline (its note is also the app icon). When the start page opens,
   the name rises in and the note dot pops on after it. At rest (and with reduced motion) it is simply the name. */
.home-logo { display: block; width: min(380px, 100%); height: auto; margin-inline: auto; color: var(--fg); overflow: visible; }
.home-logo .wv-name, .home-logo .wv-dot, .home-logo .wv-fold { transform-box: fill-box; }
.home-logo .wv-dot { transform-origin: 50% 50%; }
.home-logo .wv-fold { transform-origin: 100% 100%; }
@media (prefers-reduced-motion: no-preference) {
  .home-logo * { animation-fill-mode: both; }
  .home-logo .wv-name { animation: wv-name 700ms 120ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
  .home-logo .wv-dot { animation: wv-pop 450ms 520ms cubic-bezier(0.3, 1.2, 0.5, 1) both; }
  .home-logo .wv-fold { animation: wv-peel 280ms 850ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
}
@keyframes wv-name { from { opacity: 0; transform: translateY(18%); } }
@keyframes wv-pop { 0% { opacity: 0; transform: scale(0) rotate(-25deg); } 70% { transform: scale(1.25) rotate(6deg); } 100% { opacity: 1; transform: none; } }
@keyframes wv-peel { from { transform: scale(0); } }

.primary {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  height: 48px;
  padding: 0 28px;
  border-radius: var(--r-card);
  background: var(--fg);
  color: var(--bg);
  font-weight: 600;
  font-size: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 8px 24px rgba(0, 0, 0, 0.12);
  transition: transform 0.12s ease, box-shadow 0.14s ease, opacity 0.14s ease;
}
.primary:hover { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14), 0 12px 32px rgba(0, 0, 0, 0.18); }
.primary:active { transform: scale(0.97); }
.primary:disabled { opacity: 0.6; }

.recents h2 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 16px; }

.board-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px;
}

/* The whole card opens the board; the ⋯ button and the rename field sit above that link. */
.board-card {
  position: relative;
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
  display: flex;
  flex-direction: column;
  padding: 10px;
  border-radius: calc(var(--r-md) + 10px);
  background: var(--card);
  box-shadow: inset 0 0 0 0.5px var(--border), var(--shadow);
}
.board-card:hover { transform: translateY(-2px); box-shadow: inset 0 0 0 0.5px var(--border), var(--shadow-lg); }
.board-card:active { transform: scale(0.985); }
.board-card:has(.card-open:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.board-card.menu-open { z-index: 2; }
.card-open { position: absolute; inset: 0; z-index: 1; border-radius: inherit; outline: none; }

.card-thumb {
  aspect-ratio: 16 / 10;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--border);
}
.card-thumb svg { display: block; width: 100%; height: 100%; }
.card-thumb.empty::after {
  content: "No preview yet"; display: grid; place-items: center; height: 100%;
  font-size: 13px; color: var(--muted);
}

.pv-note rect:first-child { fill: color-mix(in srgb, var(--cat) 30%, var(--bg)); }
:root[data-theme="dark"] .pv-note rect:first-child { fill: color-mix(in srgb, var(--cat) 38%, var(--bg)); }
.pv-text { fill: var(--fg); opacity: 0.28; }
.pv-card { fill: var(--card); stroke: var(--border); stroke-width: 2; }
.pv-edge { stroke: var(--edge); }
.pv-stroke { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.pv-road { stroke: var(--fg); opacity: 0.7; stroke-dasharray: 18 6; }

.card-body { padding: 12px 4px 4px; display: flex; flex-direction: column; gap: 4px; min-height: 64px; }
.card-top { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.card-title { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-title.untitled { color: var(--muted); }
.card-meta { font-size: 13px; color: var(--muted); }
.board-card .tag {
  flex-shrink: 0; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--fg) 18%, transparent);
}

.card-more {
  position: relative; z-index: 2; flex-shrink: 0;
  width: max(30px, calc(var(--tap) - 6px)); height: max(30px, calc(var(--tap) - 6px)); margin-right: -4px; border-radius: var(--r-sm);
  display: grid; place-items: center; color: var(--muted);
}
.card-more:hover, .card-more[aria-expanded="true"] { background: var(--hover); color: var(--fg); }

.card-menu {
  position: absolute; z-index: 3; right: 8px; bottom: 44px;
  min-width: 150px; padding: 5px; border-radius: var(--r-card);
  background: var(--surface); box-shadow: inset 0 0 0 0.5px var(--border), var(--shadow-lg);
  -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
  display: flex; flex-direction: column; animation: pop 0.22s var(--ease); transform-origin: bottom right;
}
.card-menu button { height: max(34px, var(--tap)); padding: 0 10px; border-radius: var(--r-sm); text-align: left; font-size: 14px; color: var(--fg); }
.card-menu button:hover, .card-menu button:focus-visible { background: var(--hover); outline: none; }
.card-menu button.danger { color: var(--danger); }

.board-card .rename {
  position: relative; z-index: 2; flex: 1; min-width: 0; height: 30px; margin-left: -6px; padding: 0 6px;
  border: 0; border-radius: var(--r-sm); background: var(--field); box-shadow: 0 0 0 1.5px var(--accent);
  outline: none; font-size: 15px; font-weight: 600; color: var(--fg);
}
.board-card.renaming:hover { transform: none; }

.people-row { display: flex; margin-top: 6px; padding-left: 4px; }
.avatar {
  width: 26px; height: 26px; margin-left: -4px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.02em; color: #fff;
  box-shadow: 0 0 0 2px var(--card);
}
.avatar.more { background: var(--field); color: var(--muted); }

@media (max-width: 600px) {
  .home { padding-top: calc(9vh + var(--safe-top)); }
  .home-inner { gap: 44px; }
  .home-hero { gap: 12px; }
  .home-hero .primary { margin-top: 14px; }
  .home-logo { width: min(290px, 100%); }
  .tagline { font-size: 16px; }
  .board-grid { gap: 14px; }
  .card-thumb { aspect-ratio: 16 / 8; }
}
@media (prefers-reduced-motion: reduce) {
  .board-card, .primary { transition: none; }
  .board-card:hover { transform: none; }
}

/* ---------- Canvas ---------- */

.canvas {
  position: fixed;
  inset: 0;
  overflow: hidden;
  outline: none;
  cursor: default;
  background-color: var(--bg);
  background-size: var(--grid, 24px) var(--grid, 24px);
  background-position: var(--gx, 0) var(--gy, 0);
}
:root[data-bg="dots"] .canvas, :root:not([data-bg]) .canvas {
  background-image: radial-gradient(circle, var(--dot) 1px, transparent 1.2px);
}
:root[data-bg="grid"] .canvas {
  background-image: linear-gradient(var(--gridline) 1px, transparent 1px), linear-gradient(90deg, var(--gridline) 1px, transparent 1px);
}
.canvas.tool-hand, .canvas.tool-hand .item, .canvas.tool-hand .item * { cursor: grab !important; }
.canvas.panning, .canvas.panning .item, .canvas.panning .item * { cursor: grabbing !important; }
.canvas.tool-pen { cursor: crosshair; }
.canvas.tool-eraser { cursor: cell; }
.canvas.erase-part { cursor: none; }

.world {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.item { position: absolute; touch-action: none; }
.item:not(svg) { cursor: grab; transition: box-shadow 0.18s ease, transform 0.18s ease; }
/* Someone else is editing this (your own selection is drawn in .sel-layer, outside the zoom). */
.item.remote-editing:not(.selected):not(svg)::after {
  content: "";
  position: absolute;
  inset: calc(-4px * var(--inv));
  border-radius: calc(var(--r-card) + 4px * var(--inv));
  box-shadow: 0 0 0 calc(2px * var(--inv)) var(--peer);
  pointer-events: none;
}
.item.dragging { cursor: grabbing; box-shadow: var(--note-shadow-lift); }

/* Selection rings and the selection rectangle, in screen pixels so they never change with zoom. */
.sel-layer { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.sel-ring { position: absolute; left: 0; top: 0; box-sizing: border-box; border: 2px solid var(--accent); }
/* A group: dashed around all of it when it is selected as one, fainter around it while one of its cards is picked out. */
.sel-group { position: absolute; left: 0; top: 0; box-sizing: border-box; border: 1.5px dashed var(--accent); opacity: 0.5; }
.sel-group.whole { border-width: 2px; opacity: 1; background: color-mix(in srgb, var(--accent) 4%, transparent); }
/* Points and rotate handle of a recognized shape: same size at any zoom, and clickable (the layer itself is not). */
#shape-handles { position: absolute; inset: 0; }
.shape-guides { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.shape-guides path { fill: none; stroke: var(--accent); stroke-width: 1.5; opacity: 0.6; }
.shape-handle {
  position: absolute;
  left: 0;
  top: 0;
  box-sizing: border-box;
  background: var(--panel);
  border: 1.5px solid var(--accent);
  pointer-events: auto;
  touch-action: none;
}
.shape-handle::after { content: ""; position: absolute; inset: -10px; }
.shape-handle.pt { width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: var(--r-xs); cursor: crosshair; }
.shape-handle.ctl { width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--accent); cursor: crosshair; }
.shape-handle.rot { width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; cursor: grab; }
.shape-handle.rot::after { inset: -3px; } /* sits on top of the shape: keep its touch area small so the shape can still be grabbed around it */
.shape-handle.rot::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1.5px solid var(--accent);
  border-right-color: transparent;
  border-radius: 50%;
  transform: rotate(-45deg);
}
/* The rotate handle grows into a lever (stem + knob) on hover and while turning; on touch screens it is always out. */
.shape-handle.rot { transition: box-shadow 0.12s ease; }
.shape-handle.rot:hover, .shape-handle.rot.turning { box-shadow: 0 0 0 4px var(--accent-soft); }
.shape-handle.rot.turning, .shape-handle.rot.turning * { cursor: grabbing; }
.rot-arm {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  transform: rotate(var(--a, -90deg));
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.12s ease, visibility 0.12s;
}
.shape-handle.rot:hover .rot-arm, .shape-handle.rot.turning .rot-arm { visibility: visible; opacity: 1; }
@media (hover: none) { .rot-arm { visibility: visible; opacity: 1; } }
.rot-stem { position: absolute; left: 9px; top: -0.75px; width: 37px; height: 1.5px; background: var(--accent); opacity: 0.7; }
.rot-stem::after { content: ""; position: absolute; inset: -8px 0; } /* a wider strip, so the pointer can travel out to the knob */
.rot-knob {
  position: absolute;
  left: 46px;
  top: 0;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  box-sizing: border-box;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--panel);
  box-shadow: 0 0 0 1.5px var(--accent);
  cursor: grab;
}
.rot-knob::after { content: ""; position: absolute; inset: -8px; }
.marquee { position: absolute; left: 0; top: 0; border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 3px; }
.canvas.multi .item.selected .handle { display: none !important; }
.sel-count { padding: 0 8px 0 10px; font-size: 13px; font-weight: 550; color: var(--muted); white-space: nowrap; }
.item.appear { animation: appear 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
@keyframes appear { from { transform: scale(0.85); opacity: 0; } }

.peer-tag {
  position: absolute;
  left: 0;
  bottom: 100%;
  margin-bottom: 6px;
  padding: 2px 7px;
  border-radius: var(--r-xs);
  background: var(--peer);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  transform: scale(var(--inv));
  transform-origin: 0 100%;
  pointer-events: none;
}

/* Notes size themselves to what's written. */
.note {
  --cat: #fff1a8;
  width: max-content;
  min-width: 96px;
  max-width: 260px;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: var(--r-card);
  background: var(--cat);
  color: var(--cat-fg, var(--note-fg));
  box-shadow: var(--note-shadow);
}
/* Card color: Light lets the board show through, Clear keeps only a colored outline. */
:root[data-fill="light"] .note {
  background: color-mix(in srgb, var(--cat) 26%, transparent);
  color: var(--fg);
  box-shadow: none;
}
:root[data-fill="none"] .note {
  background: transparent;
  color: var(--fg);
  box-shadow: none;
}
/* Optional outline in the category's deep color (the same as its pen color). */
:root[data-theme="dark"][data-fill="light"] .note { background: color-mix(in srgb, var(--cat) 34%, transparent); }
/* Optional outline in the category color (a shade darker on full cards, so it shows). */
:root.card-outlines .note { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--cat) 70%, #000), var(--note-shadow); }
:root.card-outlines:not([data-fill="full"]) .note { box-shadow: inset 0 0 0 2px var(--cat); }

.note .text {
  min-height: 1.4em;
  font-size: 15px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  outline: none;
  cursor: inherit;
}
.note .text:empty::before { content: attr(data-placeholder); color: currentColor; opacity: 0.5; }
.note.editing { cursor: text; }
.note.editing .text { cursor: text; user-select: text; -webkit-user-select: text; }

.note .cat-label { display: none; margin-top: 8px; font-size: 10.5px; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase; opacity: 0.45; }
.show-labels .note .cat-label:not(:empty) { display: block; }

.image { border-radius: var(--r-card); box-shadow: var(--note-shadow); background: var(--card); }
.image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--r-card);
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--note-shadow);
  color: var(--fg);
}

.file { width: 240px; display: flex; align-items: center; gap: 12px; padding: 12px; }
.file .badge {
  flex-shrink: 0;
  width: 38px;
  height: 46px;
  border-radius: var(--r-xs) 12px 5px 5px;
  background: #7d8796;
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
}
.file .badge.pdf { background: #e5484d; }
.file .badge.doc { background: #2f6df6; }
.file .badge.sheet { background: #30a46c; }
.file .badge.slides { background: #f76b15; }
.file .info { min-width: 0; }
.file .fname { font-size: 14px; font-weight: 600; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.file .meta { margin-top: 3px; font-size: 12px; color: var(--muted); }

.link { width: 260px; }
.link .clip { border-radius: var(--r-card); overflow: hidden; }
.link .thumb { display: block; width: 100%; height: 136px; object-fit: cover; background: var(--field); pointer-events: none; -webkit-user-drag: none; }
.link .body { padding: 10px 12px 12px; }
.link .ltitle { font-size: 14px; font-weight: 600; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.link .ldesc { margin-top: 4px; font-size: 12.5px; line-height: 1.35; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.link .host { margin-top: 6px; display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }

/* Drawings and connectors are SVG */
svg.item { overflow: visible; pointer-events: none; }
svg.item .hit { pointer-events: stroke; stroke: transparent; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.canvas.tool-pen svg.item .hit { pointer-events: none; }
svg.stroke .ink { fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: calc(var(--w, 4) * 1px); }
/* Easy to hit (and erase) even when zoomed far out. */
svg.stroke .hit { stroke-width: max(calc((var(--w, 4) + 14) * 1px), calc(16px * var(--inv))); }
svg.draft path { stroke-width: calc(var(--w, 4) * 1px); }
svg.edge { z-index: 0; }
svg.edge .line { fill: none; stroke: var(--edge); stroke-width: 2; stroke-linecap: round; }
svg.edge .head { fill: var(--edge); }
svg.edge.selected .line { stroke: var(--accent); }
svg.edge.selected .head { fill: var(--accent); }
svg.edge.pending .line { stroke: var(--accent); stroke-dasharray: 6 6; }
svg.edge.pending .head { fill: var(--accent); }
svg.edge.pending, svg.edge.pending * { pointer-events: none !important; }
svg.draft { position: absolute; overflow: visible; pointer-events: none; z-index: 100000; }

/* Handles, kept the same size on screen at any zoom */
.handle { position: absolute; display: none; transform: scale(var(--inv)); }
.item.selected .handle { display: block; }
.item.editing .handle, .item.dragging .handle { display: none; }
.connect-handle {
  right: -34px;
  top: 50%;
  width: 22px;
  height: 22px;
  margin-top: -11px;
  border-radius: 50%;
  background: var(--panel);
  border: 1.5px solid var(--accent);
  cursor: crosshair;
  transform-origin: 0 50%;
}
.connect-handle::before {
  content: "";
  position: absolute;
  inset: 5px;
  background:
    linear-gradient(var(--accent), var(--accent)) center / 100% 1.5px no-repeat,
    linear-gradient(var(--accent), var(--accent)) center / 1.5px 100% no-repeat;
}
.connect-handle::after { content: ""; position: absolute; inset: -10px; }
.resize-handle {
  right: -7px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  border-radius: var(--r-xs);
  background: var(--panel);
  border: 1.5px solid var(--accent);
  cursor: nwse-resize;
  transform-origin: 50% 50%;
}
.resize-handle::after { content: ""; position: absolute; inset: -10px; }

.empty-hint {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  pointer-events: none;
  text-align: center;
  width: max-content;
  max-width: calc(100vw - 48px);
  text-wrap: balance;
  animation: fade 0.4s ease;
}
@keyframes fade { from { opacity: 0; } }

.drop-hint {
  position: fixed;
  inset: 12px;
  border: 2px dashed var(--accent);
  border-radius: var(--r-xl);
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  color: var(--accent);
  font-weight: 600;
  pointer-events: none;
  z-index: 40;
}

/* ---------- Floating chrome ---------- */

.pill {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 0.5px solid var(--border);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
}

/* One bar for back / name / settings / share. Its place is a setting (see layout in app.js). */
.topbar {
  position: fixed;
  z-index: 10;
  top: calc(12px + var(--safe-top) + var(--top-stack, 0px));
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 24px - var(--safe-left) - var(--safe-right));
}
:root[data-topbar-v="bottom"] .topbar { top: auto; bottom: calc(16px + var(--safe-bottom) + var(--top-stack, 0px)); }
:root[data-topbar-h="left"] .topbar { left: calc(12px + var(--safe-left)); transform: none; }
:root[data-topbar-h="right"] .topbar { left: auto; right: calc(12px + var(--safe-right) + var(--presence-gap, 0px)); transform: none; }
.topbar .title { flex: 0 1 auto; }
.topbar .sep { margin: 0 3px; }
.presence { position: fixed; z-index: 10; top: calc(12px + var(--safe-top)); right: calc(12px + var(--safe-right)); }
.pill.presence:not(:has(> :not([hidden]))) { display: none; }
.share-btn { color: var(--fg); }

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  color: var(--fg);
  transition: background 0.12s ease, transform 0.2s var(--ease);
}
.icon-btn:hover { background: var(--hover); }
.icon-btn:active { background: var(--active); transform: scale(0.94); }
.icon-btn.on { background: var(--active); }

.title {
  min-width: 0;
  width: 9ch; /* sized to the name by JS */
  max-width: 44vw;
  height: var(--tap);
  padding: 0 10px 0 4px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  font-size: 15px;
  font-weight: 600;
  outline: none;
  text-overflow: ellipsis;
  user-select: text;
  -webkit-user-select: text;
}
.title::placeholder { color: var(--muted); font-weight: 500; }

.status { font-size: 13px; color: var(--muted); padding: 0 8px; }

.people { display: flex; padding: 0 4px 0 8px; }
.people span {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--panel);
  margin-left: -7px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 650;
  color: #fff;
}
.people span:first-child { margin-left: 0; }
.people span.more { background: var(--muted); }

.share, .share:hover, .share:active { background: var(--fg); color: var(--bg); }
.share:active { transform: scale(0.97); }

.dock-wrap {
  position: fixed;
  left: 50%;
  bottom: calc(16px + var(--safe-bottom) + var(--dock-stack, 0px));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 24px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 10;
}
:root[data-dock-v="top"] .dock-wrap { bottom: auto; top: calc(12px + var(--safe-top) + var(--dock-stack, 0px)); flex-direction: column-reverse; }
:root[data-dock-h="left"] .dock-wrap { left: calc(16px + var(--safe-left)); transform: none; align-items: flex-start; }
:root[data-dock-h="right"] .dock-wrap { left: auto; right: calc(16px + var(--safe-right)); transform: none; align-items: flex-end; }
.sub { animation: rise-in 0.15s ease; }
@keyframes rise-in { from { opacity: 0; transform: translateY(4px); } }

.sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; flex-shrink: 0; }

.zoom-label {
  min-width: 52px;
  height: var(--tap);
  border-radius: var(--r-md);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.zoom-label:hover { background: var(--hover); color: var(--fg); }

.dot-btn { width: 32px; height: 32px; border-radius: var(--r-md); display: grid; place-items: center; }
.dot-btn:hover { background: var(--hover); }
.dot-btn i { display: block; width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.dot-btn.on i { box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px var(--fg); }
.size-btn { width: 32px; height: 32px; border-radius: var(--r-md); display: grid; place-items: center; }
.size-btn:hover { background: var(--hover); }
.size-btn.on { background: var(--active); }
.size-btn i { display: block; border-radius: 50%; background: var(--fg); }

.link-form { padding: 4px 4px 4px 12px; }
.link-form input { width: min(260px, 60vw); height: 32px; border: 0; background: transparent; outline: none; font-size: 14px; user-select: text; -webkit-user-select: text; }
.small-primary { height: 32px; padding: 0 12px; border-radius: var(--r-md); background: var(--fg); color: var(--bg); font-size: 13px; font-weight: 600; }

.item-tools {
  position: fixed;
  left: 0;
  top: 0;
  /* As wide as its buttons, but never wider than the screen: then it wraps onto another row. */
  width: max-content;
  max-width: calc(100vw - 16px - var(--safe-left) - var(--safe-right));
  flex-wrap: wrap;
  justify-content: center;
  transform: translate(-50%, -100%);
  animation: fade 0.12s ease;
  z-index: 20;
}
/* While the bar grows out of "Edit": the content stays centered and unsqueezed, the pill itself widens. */
.item-tools.growing { overflow: hidden; justify-content: center; }
.item-tools .tool-group { display: flex; align-items: center; gap: 2px; }
.item-tools.growing > * { flex-shrink: 0; }
#shape-handles:not([hidden]) { animation: fade 0.2s ease; }
.item-tools .text-btn { height: var(--tap); padding: 0 10px; border-radius: var(--r-md); font-size: 13.5px; font-weight: 550; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.item-tools .text-btn:hover { background: var(--hover); }
.item-tools .text-btn.on { background: var(--active); }
.cat-btn { display: flex; align-items: center; gap: 8px; height: var(--tap); padding: 0 8px 0 10px; border-radius: var(--r-md); font-size: 13.5px; font-weight: 550; max-width: 180px; }
.cat-btn:hover { background: var(--hover); }
.cat-btn .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swatch-dot { flex-shrink: 0; width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }

.menu {
  position: fixed;
  z-index: 30;
  min-width: 200px;
  max-width: 260px;
  padding: 6px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 0.5px solid var(--border);
  box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  animation: pop 0.22s var(--ease);
  transform-origin: top center;
}
@keyframes pop { from { opacity: 0; transform: scale(0.96); } }
.menu button {
  width: 100%;
  height: max(36px, var(--tap));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border-radius: var(--r-md);
  font-size: 14px;
  text-align: left;
}
.menu button:hover, .menu button:focus-visible { background: var(--hover); outline: none; }
.menu .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu .label.unnamed { color: var(--muted); }
.menu .check { color: var(--accent); }
.menu hr { border: 0; height: 1px; background: var(--border); margin: 6px 4px; }
.menu .subtle { color: var(--muted); }

/* ---------- Settings sheet ---------- */

.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.16); animation: fade 0.18s ease; }
.sheet {
  position: absolute;
  top: calc(12px + var(--safe-top));
  right: calc(12px + var(--safe-right));
  bottom: calc(12px + var(--safe-bottom));
  width: 380px;
  max-width: calc(100vw - 24px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--r-xl);
  background: var(--grouped);
  border: 0.5px solid var(--border);
  box-shadow: var(--shadow-lg);
  user-select: none;
  -webkit-user-select: none;
  animation: slide-in 0.36s var(--ease);
}
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }

.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 0 20px; }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }

/* Board / This device */
.tabs { display: flex; flex-shrink: 0; gap: 2px; margin: 12px 20px 0; padding: 3px; border-radius: var(--r-md); background: var(--field); }
.tab { flex: 1; height: 30px; border-radius: var(--r-sm); font-size: 13px; font-weight: 550; color: var(--muted); transition: color 0.12s ease; }
.tab:hover { color: var(--fg); }
.tab.on { background: var(--thumb); color: var(--fg); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 0.5px 1px rgba(0, 0, 0, 0.1); }
.tab:focus-visible { outline-offset: 1px; }

.sheet-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 20px 24px; touch-action: pan-y; }
.scope { margin: 14px 2px 0; font-size: 12.5px; line-height: 1.45; color: var(--muted); }

.group { margin-top: 22px; }
.group h3 { margin: 0 0 7px 14px; font-size: 13px; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.set-note { margin: 8px 2px 0; font-size: 12px; line-height: 1.45; color: var(--muted); }

/* A group of rows */
.set-card { background: var(--grouped-card); border: 0.5px solid var(--border); border-radius: var(--r-card); overflow: hidden; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; min-height: 48px; padding: 8px 14px; font-size: 14px; text-align: left; }
.row + .row { box-shadow: inset 0 0.5px 0 var(--border); } /* hairline separator */
.row-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.row-label { line-height: 1.3; }
.row-desc { font-size: 12px; line-height: 1.35; color: var(--muted); }
.row.toggle, .row.action { cursor: pointer; }
.row.action { color: var(--fg); }
.row.action svg { flex-shrink: 0; color: var(--muted); }
.row.action:hover { background: var(--hover); }
.row.action:focus-visible { outline-offset: -2px; }
.row:has(.row-input):focus-within { background: var(--hover); }
.row-input {
  flex: 1;
  min-width: 0;
  height: 32px;
  border: 0;
  background: transparent;
  outline: none;
  text-align: right;
  user-select: text;
  -webkit-user-select: text;
}
/* Keep the typing area rounded like the buttons: no square browser highlight (autofill/focus). */
.row-input { padding: 0 12px; border-radius: var(--r-md); transition: background 0.2s var(--ease), box-shadow 0.2s var(--ease); }
.row-input:focus { background: var(--field); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent); }
.row-input:-webkit-autofill, .row-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--fg);
  -webkit-box-shadow: 0 0 0 40px var(--field) inset;
  border-radius: var(--r-md);
  caret-color: var(--fg);
  transition: background-color 9999s ease-out;
}
.row-input::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 4px; }
.row-input::placeholder, .cat-list input::placeholder { color: var(--muted); opacity: 0.8; }

.segmented { display: flex; flex-shrink: 0; padding: 2px; border-radius: var(--r-md); background: var(--field); }
.segmented button { height: 28px; transition: background 0.2s var(--ease), color 0.12s ease; padding: 0 11px; border-radius: var(--r-sm); font-size: 13px; color: var(--muted); }
.segmented button:hover:not(.on) { color: var(--fg); }
.segmented button.on { background: var(--thumb); color: var(--fg); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 0.5px 1px rgba(0, 0, 0, 0.1); font-weight: 590; }
.segmented button:focus-visible { outline-offset: 0; }

.toggle input {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  position: relative;
  width: 46px;
  height: 28px;
  margin: 0;
  border-radius: 999px;
  background: var(--fill);
  cursor: pointer;
  transition: background 0.15s ease;
}
.toggle input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
  transition: transform 0.3s var(--ease);
}
.toggle input:checked { background: var(--on); }
.toggle input:checked::after { transform: translateX(18px); }

/* Where a bar sits on screen: a tiny 3 x 2 map of the window */
.placement { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); flex-shrink: 0; gap: 2px; width: 96px; height: 52px; padding: 2px; border-radius: var(--r-md); background: var(--field); }
.placement button { position: relative; border-radius: var(--r-sm); }
.placement button::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 2px;
  background: var(--muted);
  opacity: 0.4;
  transition: all 0.15s ease;
}
.placement button:hover::after { opacity: 0.9; }
.placement button[aria-checked="true"] { background: var(--thumb); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 0.5px 1px rgba(0, 0, 0, 0.1); }
.placement button[aria-checked="true"]::after { width: 14px; margin-left: -7px; background: var(--fg); opacity: 1; }
.placement button:focus-visible { outline-offset: 0; }

/* Categories */
.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-list li { display: flex; align-items: center; gap: 10px; padding: 0 14px; }
.cat-list li + li { border-top: 1px solid var(--border); }
.cat-list li:focus-within { background: var(--hover); }
.cat-list input { flex: 1; min-width: 0; height: 44px; border: 0; background: transparent; outline: none; font-size: 14px; user-select: text; -webkit-user-select: text; }
.cat-list .swatch-dot { width: 18px; height: 18px; }
.cat-list li.off .swatch-dot { opacity: 0.35; }
.cat-key { width: 12px; flex-shrink: 0; font-size: 12px; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }

/* Keyboard shortcuts */
.collapsible { background: var(--grouped-card); border: 0.5px solid var(--border); border-radius: var(--r-card); overflow: hidden; }
.collapsible > summary { display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 0 14px; cursor: pointer; list-style: none; }
.collapsible > summary::-webkit-details-marker { display: none; }
.collapsible > summary h3 { margin: 0; font-size: 14px; font-weight: 400; letter-spacing: 0; color: var(--fg); }
.collapsible > summary:hover { background: var(--hover); }
.collapsible > summary:focus-visible { outline-offset: -2px; }
.collapsible .chev { color: var(--muted); transition: transform 0.15s ease; }
.collapsible[open] .chev { transform: rotate(180deg); }
.collapsible[open] > summary { border-bottom: 1px solid var(--border); }

.text-btn { height: 36px; padding: 0 4px; font-size: 14px; font-weight: 550; color: var(--accent); }

.toast {
  /* Placed next to the dock by placeToast() in app.js, so it never covers the menus that open above it. */
  position: fixed;
  left: 50%;
  top: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--r-card);
  background: var(--fg);
  color: var(--bg);
  font-size: 14px;
  box-shadow: var(--shadow);
  white-space: nowrap;
  animation: rise 0.18s ease;
  z-index: 60;
}
.toast button { font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }

@media (max-width: 560px) {
  .wide-only { display: none !important; }
  .sheet {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    height: 88vh;
    height: 88dvh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    animation-name: slide-up;
  }
  .sheet-body { padding-bottom: calc(24px + var(--safe-bottom)); }
  @keyframes slide-up { from { transform: translateY(40px); opacity: 0; } }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Settings: color strength, any-color picker, pen */
.slider { display: flex; align-items: center; gap: 8px; }
.slider small { font-size: 12px; color: var(--muted); }
.slider input { width: 120px; accent-color: var(--fg); }
.custom-color, .pen-colors label { position: relative; cursor: pointer; }
.custom-color i { background: conic-gradient(#ff6b6b, #ffd93d, #6bcb77, #4d96ff, #b06bff, #ff6b6b); }
.custom-color input, .pen-colors input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.pen-colors { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 8px; }
.pen-colors .dot-btn i { width: 22px; height: 22px; }
.ink-dot { cursor: default; }
.pen-sizes { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 2px; }
.pen-sizes li { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.pen-sizes .size-num { width: 14px; font-size: 13px; color: var(--muted); text-align: center; }
.pen-sizes svg path { stroke: var(--fg); }
.pen-sizes input { flex: 1; min-width: 0; accent-color: var(--fg); }
.pen-sizes .size-val { width: 22px; font-size: 13px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

/* Zoom, bottom right (can be hidden in settings) */
.zoom-ctl {
  position: fixed;
  right: calc(16px + var(--safe-right));
  bottom: calc(16px + var(--safe-bottom) + var(--zoom-lift, 0px));
  z-index: 10;
  touch-action: none;
}
.zoom-ctl[hidden] { display: none; }

/* Dock pop-ups: pen panel and the + menu */
.pen-panel { flex-direction: row; align-items: center; gap: 2px; padding: 4px; max-width: 100%; }
.pen-panel .icon-btn { width: 32px; height: 32px; border-radius: var(--r-md); }
.pen-panel .mode-btn { color: var(--muted); }
.pen-panel .mode-btn.on { color: var(--fg); background: var(--active); }
.size-btn i.ring { background: transparent; box-shadow: inset 0 0 0 1.5px var(--fg); }
.add-menu { gap: 2px; }
.add-item { display: flex; align-items: center; gap: 8px; height: max(40px, var(--tap)); padding: 0 12px 0 10px; border-radius: var(--r-md); font-size: 14px; font-weight: 550; }
.add-item:hover { background: var(--hover); }
kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border-radius: var(--r-xs);
  border: 1px solid var(--border);
  font: 500 11px/1.4 var(--font);
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
}
.menu kbd { margin-left: auto; }
.icon-btn#add-btn.on { background: var(--active); }
#add-btn svg { transition: transform 0.15s ease; }
#add-btn.on svg { transform: rotate(45deg); }

/* Part eraser: shows exactly what it will take away */
.eraser-cursor {
  position: fixed;
  left: 0;
  top: 0;
  border-radius: 50%;
  border: 1.5px solid var(--fg);
  background: color-mix(in srgb, var(--bg) 40%, transparent);
  pointer-events: none;
}

/* Settings: pen palette and the shortcut list */
.pen-swatch { position: relative; display: inline-grid; }
.swatch-del {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--fg);
  color: var(--bg);
  opacity: 0;
  transition: opacity 0.12s ease;
}
.pen-swatch:hover .swatch-del, .swatch-del:focus-visible { opacity: 1; }
@media (pointer: coarse) {
  .swatch-del { opacity: 0.85; }
  .no-touch { display: none !important; }
}
.add-color { color: var(--muted); border: 1.5px dashed var(--border); width: 30px; height: 30px; margin: 1px; border-radius: 50%; }
.add-color:hover { color: var(--fg); }
.keys-list { margin: 0; padding: 4px 14px 12px; }
.keys-list h4 { margin: 14px 0 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.keys-list h4:first-child { margin-top: 10px; }
.key-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 13.5px; }
.key-row dt { flex-shrink: 0; order: 2; }
.key-row dd { margin: 0; }
@media (max-width: 560px) {
  .pen-panel { gap: 0; padding: 3px; }
  .pen-panel .icon-btn, .pen-panel .dot-btn, .pen-panel .size-btn { width: 27px; height: 32px; }
  .pen-panel .sep { margin: 0 2px; }
  .title { max-width: calc(100vw - 150px - var(--safe-left) - var(--safe-right)); }
  :root:not([data-topbar-v="bottom"]) .presence { top: calc(64px + var(--safe-top)); }
}

.alpha-btn i { box-shadow: inset 0 0 0 1px rgba(127, 127, 127, 0.35); }

/* Hover tooltips (name + shortcut), see Settings → Shortcut tooltips */
.tooltip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  padding: 5px 8px;
  border-radius: var(--r-sm);
  background: var(--fg);
  color: var(--bg);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.3;
  pointer-events: none;
  box-shadow: var(--shadow);
  animation: fade 0.12s ease;
}
.tooltip[hidden] { display: none; }
.tooltip kbd { color: inherit; border-color: color-mix(in srgb, var(--bg) 40%, transparent); opacity: 0.85; }

/* ---------- Confirm dialog ---------- */
.dialog-wrap { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 24px; background: rgba(0, 0, 0, 0.28); animation: fade 0.14s ease; }
.dialog {
  width: min(340px, 100%);
  padding: 20px;
  border-radius: var(--r-lg);
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: pop 0.16s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
@keyframes pop { from { opacity: 0; transform: scale(0.96); } }
.dialog h2 { margin: 0 0 6px; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.dialog p { margin: 0; font-size: 14px; line-height: 1.45; color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.dialog-actions button { height: 36px; padding: 0 16px; border-radius: var(--r-md); font-size: 14px; font-weight: 600; background: var(--field); }
.dialog-actions button:hover { background: var(--active); }
.dialog-actions .danger { background: var(--danger); color: #fff; }
.dialog-actions .danger:hover { background: color-mix(in srgb, var(--danger) 88%, #000); }

/* ---------- Other people: pointers, drawings in progress, who added what ---------- */

/* Pointers live inside the zoomed board and are scaled back, so they stay the same size at any zoom. */
.remote-cursor {
  --c: #888;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2147483000;
  pointer-events: none;
  transform-origin: 0 0;
  transition: transform 70ms linear, opacity 0.4s ease;
  will-change: transform;
}
.remote-cursor svg { display: block; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3)); }
.remote-cursor .cursor-name {
  position: absolute;
  left: 13px;
  top: 17px;
  padding: 2px 8px;
  border-radius: var(--r-md);
  background: var(--c);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.45;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.remote-cursor.idle { opacity: 0.4; }

.author-tag {
  display: none;
  position: absolute;
  left: 2px;
  top: 100%;
  margin-top: 5px;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  color: var(--muted);
  white-space: nowrap;
  pointer-events: none;
}
.author-tag i { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.show-authors .author-tag { display: flex; }
.far .author-tag { display: none; } /* too small to read when zoomed far out */

.author-info {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 8px 0 10px;
  font-size: 13px;
  font-weight: 550;
  color: var(--muted);
  white-space: nowrap;
}
.author-info i { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* ---------- Comments ---------- */

.comment-panel {
  position: fixed;
  z-index: 25;
  width: 320px;
  max-height: min(460px, calc(100vh - 88px));
  display: flex;
  flex-direction: column;
  border-radius: var(--r-xl);
  background: var(--surface);
  border: 0.5px solid var(--border);
  box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  animation: pop 0.22s var(--ease);
  transform-origin: left top;
  touch-action: auto;
}
.comment-top { display: flex; align-items: center; justify-content: space-between; padding: 8px 6px 2px 16px; }
.comment-top h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -0.01em; display: flex; align-items: center; gap: 6px; }
.comment-count { color: var(--muted); font-weight: 550; font-variant-numeric: tabular-nums; }
.comment-top .icon-btn { color: var(--muted); }
.comment-top .icon-btn:hover { background: var(--hover); color: var(--fg); }

.comment-list { list-style: none; margin: 0; padding: 4px 8px; overflow-y: auto; overscroll-behavior: contain; min-height: 0; flex: 1; }
.comment { display: flex; gap: 10px; padding: 8px; border-radius: var(--r-md); }
.comment .avatar { flex: none; margin: 1px 0 0; width: 26px; height: 26px; box-shadow: none; }
.comment-body { flex: 1; min-width: 0; }
.comment-head { display: flex; align-items: baseline; gap: 6px; min-height: 18px; }
.comment-name { font-size: 13px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comment-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.comment-text { margin: 2px 0 0; font-size: 14px; line-height: 1.42; white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }
.comment-del { width: 26px; height: 26px; margin: -5px -4px -5px auto; align-self: center; color: var(--muted); opacity: 0; }
.comment-del svg { width: 15px; height: 15px; }
.comment:hover .comment-del, .comment-del:focus-visible { opacity: 1; }
.comment-del:hover { color: var(--danger); background: var(--hover); }
@media (hover: none) { .comment-del { opacity: 1; } }
.comment-empty { padding: 10px 8px 14px; font-size: 13.5px; color: var(--muted); }

.comment-form { display: flex; align-items: flex-end; gap: 6px; margin: 4px 10px 10px; padding: 5px 5px 5px 12px; border-radius: var(--r-lg); background: var(--field); }
.comment-form textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 14px;
  line-height: 20px;
  padding: 5px 0;
  max-height: 120px;
  user-select: text;
  -webkit-user-select: text;
}
.comment-form textarea::placeholder { color: var(--muted); }
.comment-send { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--fg); color: var(--bg); transition: opacity 0.12s ease; }
.comment-form:has(textarea:placeholder-shown) .comment-send { opacity: 0.3; pointer-events: none; }

/* On a phone: a sheet along the bottom, above the keyboard. */
.comment-panel.docked {
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  width: auto;
  max-height: 60vh;
  max-height: 60dvh;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding-bottom: var(--safe-bottom);
  animation-name: slide-up; /* defined with the settings sheet */
}
@media (pointer: coarse) { .comment-form textarea { font-size: 16px; } } /* no zoom-in on focus in iOS Safari */

.item-tools .text-btn.unread { position: relative; }
.item-tools .text-btn.unread::after { content: ""; position: absolute; top: 7px; left: 22px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--panel); }
.comment-new { display: flex; align-items: center; gap: 8px; margin: 2px 8px; font-size: 11px; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); }
.comment-new::after { content: ""; flex: 1; height: 1px; background: var(--accent); opacity: 0.4; }

/* Reactions: small chips, an icon and how many. Yours are filled: blue thumbs, a red heart. */
.reactions { display: flex; flex-wrap: wrap; gap: 4px; }
.reaction {
  --tint: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 24px;
  padding: 0 7px 0 6px;
  border-radius: 12px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 0 0 0.5px var(--border), 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: transform 0.15s var(--ease), background 0.12s ease, color 0.12s ease;
}
.reaction.heart { --tint: var(--danger); }
.reaction svg { width: 14px; height: 14px; fill: none; flex: none; }
.reaction .n { color: var(--fg); }
.reaction:hover { background: var(--grouped); color: var(--fg); }
.reaction:active { transform: scale(0.92); }
.reaction.mine { color: var(--tint); background: color-mix(in srgb, var(--tint) 12%, var(--panel)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tint) 55%, transparent); }
.reaction.mine svg { fill: currentColor; }
.reaction.mine .n { color: var(--tint); }

/* In the thread: all three, the unused ones quiet until hovered. */
.reactions.in-panel { padding: 2px 14px 8px; }
.reactions.in-panel .reaction { height: 28px; padding: 0 8px; }
.reactions.in-panel .reaction svg { width: 17px; height: 17px; }
.reaction.empty { background: transparent; box-shadow: none; padding: 0 8px; }
.reaction.empty:hover { color: var(--tint); background: var(--hover); }

/* One button on a card for what people think of it: the comment count, then each reaction with how many.
   Along the card's bottom edge, the same size on screen at any zoom. Blue when there are comments you have not read. */
.card-pill {
  position: absolute;
  right: 12px;
  top: 100%;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 30px;
  padding: 0 11px;
  border-radius: 15px;
  background: var(--panel);
  color: var(--fg);
  font-size: 14px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  box-shadow: 0 0 0 0.5px var(--border), 0 1px 4px rgba(0, 0, 0, 0.12);
  /* Part of the card: it grows and shrinks with the board, like the card itself. */
  transform-origin: 100% 0;
  transform: translateY(-50%);
  cursor: pointer;
  transition: background 0.12s ease, transform 0.2s var(--ease);
}
/* While the card is selected it moves just below the selection ring (drawn at the same size on screen), instead of being cut by it. */
.item.selected .card-pill { transform: translateY(calc(7px * var(--inv) + 2px)); }
.card-pill:hover { background: var(--grouped); }
.card-pill .seg { --tint: var(--accent); display: flex; align-items: center; gap: 4px; }
.card-pill svg { width: 17px; height: 17px; fill: none; flex: none; }
.card-pill .seg.heart { --tint: var(--danger); }
.card-pill .seg.mine { color: var(--tint); }
.card-pill .seg.mine svg { fill: currentColor; }
.card-pill.unread { background: var(--accent); color: #fff; box-shadow: 0 0 0 0.5px var(--accent), 0 1px 6px var(--accent-soft); }
.card-pill.unread:hover { background: var(--accent); filter: brightness(1.08); }
.card-pill.unread .seg.mine { color: #fff; }
/* Zoomed far out it would cover the small cards: just a dot, blue when there is something new. */
.far .card-pill, .far .item.selected .card-pill { width: 11px; height: 11px; padding: 0; gap: 0; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 1.5px var(--bg); transform: scale(var(--inv)) translate(50%, -50%); }
.far .card-pill.unread { background: var(--accent); }
.far .card-pill > * { display: none; }


/* ---------- Who are you? (a new device on a board picks a person from the group) ---------- */
.who-wrap {
  position: fixed;
  inset: 0;
  z-index: 65;
  display: grid;
  place-items: center;
  padding: calc(20px + var(--safe-top)) 16px calc(20px + var(--safe-bottom));
  overflow-y: auto;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  animation: fade 0.2s ease;
}
.who {
  width: min(460px, 100%);
  padding: 26px 22px 18px;
  border-radius: var(--r-xl);
  background: var(--panel);
  border: 0.5px solid var(--border);
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: pop 0.22s var(--ease);
}
.who h2 { margin: 0; font-size: 22px; font-weight: 680; letter-spacing: -0.02em; }
.who-sub { margin: 6px auto 0; max-width: 34ch; font-size: 14px; line-height: 1.45; color: var(--muted); }
.who-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; margin-top: 20px; }
.who-person {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 16px 8px 13px;
  border-radius: var(--r-card);
  background: var(--field);
  transition: background 0.14s ease, transform 0.16s var(--ease), box-shadow 0.14s ease;
}
.who-person:hover:not(:disabled) { background: var(--active); }
.who-person:active:not(:disabled) { transform: scale(0.96); }
.who-person.match { box-shadow: inset 0 0 0 2px var(--accent); }
.who-person:disabled { opacity: 0.55; cursor: default; }
.who-avatar.avatar { width: 52px; height: 52px; margin: 0; font-size: 18px; box-shadow: none; }
.who-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; font-weight: 600; }
.who-tag { font-size: 11.5px; color: var(--muted); margin-top: -4px; }
.who-tag.here::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: var(--on); vertical-align: 0.5px; }
.who-foot { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-top: 14px; }
.who-link { height: 36px; padding: 0 12px; border-radius: var(--r-md); font-size: 14px; font-weight: 600; color: var(--accent); }
.who-link:hover { background: var(--hover); }
.who-link.muted { color: var(--muted); font-weight: 500; }
.who-new { display: flex; gap: 8px; width: 100%; margin: 4px 0 6px; }
.who-new[hidden] { display: none; }
.who-new input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--field);
  font-size: 15px;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}
.who-new input:focus { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent); }
.who-new .small-primary { height: 40px; padding: 0 16px; }

/* ---------- Settings → People ---------- */
.member-list { list-style: none; margin: 0; padding: 0; }
.member-list li { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 6px 0 14px; }
.member-list li + li, .member-add { box-shadow: inset 0 0.5px 0 var(--border); }
.member-list li:focus-within { background: var(--hover); }
.member-list input { flex: 1; min-width: 0; height: 44px; border: 0; background: transparent; outline: none; font-size: 14px; user-select: text; -webkit-user-select: text; }
.member-list input::placeholder, .member-add input::placeholder { color: var(--muted); opacity: 0.8; }
.member-color { flex: none; width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); transition: transform 0.16s var(--ease); }
.member-color:hover { transform: scale(1.12); }
.member-tag { flex: none; font-size: 12px; color: var(--muted); padding-right: 8px; }
.member-tag.here::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: var(--on); vertical-align: 1px; }
.member-del { width: 32px; height: 32px; color: var(--muted); }
.member-list li.member-colors { gap: 8px; min-height: 44px; padding-left: 46px; box-shadow: none; background: transparent; }
.member-swatch { width: 22px; height: 22px; border-radius: 50%; transition: transform 0.16s var(--ease); }
.member-swatch:hover { transform: scale(1.12); }
.member-swatch.on { box-shadow: 0 0 0 2px var(--grouped-card), 0 0 0 4px currentColor; color: var(--fg); }
.member-add { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 8px 0 14px; }
.member-add:focus-within { background: var(--hover); }
.member-plus { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--field); color: var(--muted); }
.member-add input { flex: 1; min-width: 0; height: 44px; border: 0; background: transparent; outline: none; font-size: 14px; user-select: text; -webkit-user-select: text; }
.member-add .small-primary { height: 30px; }
.set-card.spaced { margin-top: 12px; }
#people-section[hidden], #switch-person[hidden] { display: none; }
.agent-list li { padding: 8px 8px 8px 14px; }
.agent-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.agent-name { font-size: 14px; font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-when { font-size: 12px; color: var(--muted); }
.agent-remove { flex: none; padding: 6px 10px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--danger); }
.agent-remove:hover { background: var(--hover); }
.agent-remove:disabled { opacity: 0.5; }
.agent-list li.agent-none { font-size: 13px; color: var(--muted); padding: 12px 14px; line-height: 1.4; }
.nowrap { white-space: nowrap; }

/* ---------- Video call ---------- */
.call-btn { position: relative; }
.call-btn.on { background: var(--active); color: var(--on); }
.call-btn.live { background: var(--on); color: #fff; }
.call-btn.live:hover { background: color-mix(in srgb, var(--on) 88%, #000); }
.call-btn.busy { opacity: 0.6; }
.call-count {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--fg);
  color: var(--bg);
  font-size: 10px;
  font-weight: 700;
  line-height: 15px;
}
.call-count[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .call-btn.live { animation: call-ring 2.4s ease-in-out infinite; }
}
@keyframes call-ring { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--on) 50%, transparent); } 50% { box-shadow: 0 0 0 5px transparent; } }

/* The call card. Its padding is the same on every side and on every device: the tiles stretch to the
   card's full width, so a button row wider than the tiles (more buttons, or 44px touch buttons) no
   longer leaves a strip of empty space on one side. Corners nest: card radius = tile radius + padding. */
.call-panel {
  --tw: 196px;
  --cols: 1;
  --pad: 8px;
  --tile-r: var(--r-md);
  position: fixed;
  z-index: 30;
  top: calc(64px + var(--safe-top));
  right: calc(12px + var(--safe-right));
  flex-direction: column;
  align-items: stretch;
  gap: var(--pad);
  padding: var(--pad);
  border-radius: calc(var(--tile-r) + var(--pad));
  box-shadow: var(--shadow-lg);
  max-height: calc(100dvh - 90px - var(--safe-top) - var(--safe-bottom));
  animation: pop 0.2s var(--ease);
  touch-action: none;
}
.call-tiles {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(var(--tw), 1fr));
  gap: 6px;
  min-height: 0;
  overflow-y: auto;
  cursor: grab;
  scrollbar-width: none;
}
.call-tiles:active { cursor: grabbing; }
.call-panel:has(.call-tile:nth-child(4)) { --tw: 150px; }
.call-tile {
  --c: var(--edge);
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--tile-r);
  background: #2a2a2d;
  outline: 0.5px solid rgba(255, 255, 255, 0.07);
  outline-offset: -0.5px;
  transition: outline-color 0.15s ease, outline-width 0.15s ease;
}
.call-tile:not(.self) { cursor: zoom-in; }
/* An outline is drawn over the video (an inset shadow would sit under it). */
.call-tile.speaking { outline: 2px solid var(--on); outline-offset: -2px; }
.call-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #1c1c1e; }
.call-tile.self:not(.screen):not(.rear) video { transform: scaleX(-1); } /* like a mirror, but not for the back camera */
.call-tile.screen video { object-fit: contain; }
.call-tile.nocam video { opacity: 0; }
.call-face { position: absolute; inset: 0; display: none; place-items: center; background: radial-gradient(circle at 50% 42%, #333336, #252528 70%); }
.call-tile.nocam .call-face { display: grid; }
.call-avatar.avatar { width: 38%; max-width: 64px; height: auto; aspect-ratio: 1; margin: 0; font-size: 18px; box-shadow: none; }
.call-name {
  position: absolute;
  z-index: 1;
  left: 6px;
  bottom: 6px;
  max-width: calc(100% - 12px);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: calc(var(--tile-r) - 4px);
  background: rgba(0, 0, 0, 0.42);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: #fff;
  font-size: 11.5px;
  font-weight: 550;
  line-height: 1.45;
}
.call-who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-muted { display: flex; color: #ff6961; }
.call-muted[hidden] { display: none; }
.call-tile.weak::after {
  content: "Reconnecting…";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 12px;
}
/* The buttons span the card: the first lines up with the tiles' left edge, Leave with their right edge. */
.call-bar { display: flex; justify-content: space-between; align-items: center; gap: 4px; }
.call-bar .icon-btn { border-radius: calc(var(--tile-r) - 2px); }
.call-bar .icon-btn.off { color: var(--danger); }
.call-bar .icon-btn.on { color: var(--accent); }
.call-bar .icon-btn:disabled { opacity: 0.5; pointer-events: none; }
.call-bar .icon-btn.call-leave { width: calc(var(--tap) * 1.4); background: var(--danger); color: #fff; }
.call-bar .icon-btn.call-leave:hover { background: color-mix(in srgb, var(--danger) 88%, #000); }
.call-bar .icon-btn.call-rec.recording { color: var(--danger); }
@media (prefers-reduced-motion: no-preference) {
  .call-bar .icon-btn.call-rec.recording svg { animation: rec-pulse 1.2s ease-in-out infinite; }
}

/* Someone is recording the call: a line at the top, and a mark on their tile. */
.call-rec-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--danger);
}
.call-rec-note[hidden] { display: none; }
.call-rec-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-tile.recording::before {
  content: "REC";
  position: absolute;
  z-index: 1;
  top: 6px;
  right: 6px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* Someone's tile big, the rest in a strip below it. The big tile takes the shape of that person's video
   (--far, set in call.js), as large as fits on the screen, so the whole picture shows, nothing cut off. */
.call-panel.has-focus {
  --strip: 76px;
  --fw: min(66vw, 860px, calc((100dvh - 230px - var(--safe-top) - var(--safe-bottom)) * var(--far, 1.3333)));
}
/* The width goes on the card (plus its padding and hairline border), not on the grid: the tiles then stretch to
   the card, so a wider button row still leaves the same padding on every side. */
.call-panel.has-focus { min-width: calc(var(--fw) + 2 * var(--pad) + 1px); }
.call-panel.has-focus .call-tiles { grid-template-columns: repeat(auto-fill, minmax(var(--strip), 1fr)); }
.call-panel.has-focus .call-tile.focus { grid-column: 1 / -1; aspect-ratio: var(--far, 4 / 3); cursor: zoom-out; }
.call-panel.has-focus .call-tile.focus video { object-fit: contain; background: #000; }
.call-panel.has-focus .call-tile:not(.focus) .call-name { display: none; }

/* Smaller: round faces in a row, in the middle of the card. */
.call-panel.mini { --tw: 52px; }
.call-panel.mini .call-tiles { grid-template-columns: repeat(var(--cols), var(--tw)); justify-content: center; }
.call-panel.mini .call-tile { aspect-ratio: 1; border-radius: 50%; corner-shape: round; }
.call-panel.mini .call-name { display: none; }
.call-panel.mini .call-avatar.avatar { width: 100%; max-width: none; font-size: 15px; }

@media (max-width: 600px) {
  .call-panel { --tw: 104px; --pad: 6px; top: calc(112px + var(--safe-top)); right: calc(8px + var(--safe-right)); }
  .call-panel:has(.call-tile:nth-child(4)) { --tw: 96px; }
  .call-panel.mini { --tw: 44px; }
  .call-panel.has-focus {
    --strip: 60px;
    --fw: min(calc(100vw - 17px - 2 * var(--pad) - var(--safe-left) - var(--safe-right)), calc((100dvh - 300px - var(--safe-top) - var(--safe-bottom)) * var(--far, 1.3333)));
  }
  .call-name { font-size: 10.5px; padding: 1px 6px; left: 4px; bottom: 4px; max-width: calc(100% - 8px); }
}
:root[data-topbar-v="bottom"] .call-panel { top: calc(12px + var(--safe-top)); }
.who:focus { outline: none; }


/* ---------- Voice: voice cards, voice comments, recording ---------- */

/* Sized and shaped like a note (48 high for the player row, up to 260 wide, the same corners, no border),
   so a selection ring sits on it the same way. */
.voice.card { border: 0; }
.voice { width: 260px; min-height: 48px; padding: 6px 14px 6px 6px; display: flex; flex-direction: column; gap: 4px; }
.voice .vhead { display: flex; padding: 6px 0 2px 8px; }
.voice .vname { font-size: 13px; font-weight: 600; line-height: 1.3; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice .vid {
  display: block;
  width: calc(100% + 20px);
  margin: -6px -14px 2px -6px;
  max-height: 420px;
  object-fit: cover;
  background: #000;
  border-radius: var(--r-card) var(--r-card) 0 0;
  pointer-events: none;
}
.voice:has(.vid) .vhead { order: 2; }
.voice:has(.vid) .player { order: 3; }
.voice:has(.vid) .tx { order: 4; }

.player { display: flex; align-items: center; gap: 10px; min-width: 0; }
.player .play {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--fg);
  color: var(--bg);
  transition: transform 0.12s ease;
}
.player .play svg { margin-left: 1px; }
.player.playing .play svg { margin-left: 0; }
.player .play:active { transform: scale(0.94); }
.player .wave { flex: 1; min-width: 0; height: 30px; display: flex; align-items: center; gap: 2px; cursor: pointer; touch-action: none; }
.player .wave i { flex: 1; min-width: 1.5px; max-width: 4px; border-radius: 2px; background: var(--fg); opacity: 0.22; transition: opacity 0.12s ease; }
.player .wave i.on { opacity: 0.9; background: var(--accent); }
.player.no-wave .wave i { height: 22% !important; }
.player .time { flex: none; min-width: 30px; text-align: right; font-size: 12px; font-weight: 550; font-variant-numeric: tabular-nums; color: var(--muted); }
.player.compact { gap: 8px; margin: 4px 0 2px; }
.player.compact .play { width: 30px; height: 30px; }
.player.compact .play svg { width: 13px; height: 13px; }
.player.compact .wave { height: 24px; }

.voice .tx { border-top: 1px solid var(--border); margin: 2px -14px 0 -6px; padding: 6px 14px 4px 14px; }
.voice .tx-bar { display: flex; align-items: center; gap: 6px; min-height: 22px; }
.voice .tx-toggle { display: inline-flex; align-items: center; gap: 2px; margin-left: -6px; padding: 2px 4px 2px 6px; border-radius: var(--r-xs); font-size: 12px; font-weight: 600; color: var(--muted); }
.voice .tx-toggle:hover { background: var(--hover); color: var(--fg); }
.voice .tx-toggle svg { transition: transform 0.18s var(--ease); transform: rotate(-90deg); }
.voice.tx-open .tx-toggle svg { transform: none; }
.voice .tx-state { font-size: 12px; color: var(--muted); }
.voice .tx[data-state="pending"] .tx-state::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin: 0 6px -1px 0;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.voice .text {
  margin: 2px 0 2px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  outline: none;
  cursor: inherit;
}
.voice .tx[data-state="pending"] .text { color: var(--muted); }
.voice.editing { cursor: default; }
.voice.editing .text { cursor: text; user-select: text; -webkit-user-select: text; border-radius: var(--r-xs); box-shadow: 0 0 0 4px var(--field); background: var(--field); }
.voice.selected .tx[data-state="done"] .text { cursor: text; }

/* Recording a voice card: the bar above the dock. */
.rec-bar { gap: 8px; padding: 4px 4px 4px 4px; max-width: min(520px, calc(100vw - 24px)); }
.rec-bar .icon-btn { width: 32px; height: 32px; border-radius: var(--r-md); color: var(--muted); }
.rec-bar .icon-btn:hover { color: var(--fg); background: var(--hover); }
.rec-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); animation: rec-pulse 1.2s ease-in-out infinite; }
@keyframes rec-pulse { 50% { opacity: 0.35; } }
.rec-time { flex: none; min-width: 34px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rec-bar.near-end .rec-time { color: var(--danger); }
.rec-meter { flex: none; display: flex; align-items: center; gap: 2px; height: 18px; }
.rec-meter i { width: 3px; height: 18px; border-radius: 2px; background: var(--fg); transform: scaleY(0.18); transition: transform 0.06s linear; }
.rec-words {
  flex: 1;
  min-width: 0;
  width: 240px;
  font-size: 13px;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  direction: rtl; /* the newest words stay in view */
  text-align: left;
  text-overflow: ellipsis;
}
.rec-words.waiting { color: var(--muted); direction: ltr; }
.rec-stop { flex: none; width: 36px; height: 32px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--danger); color: #fff; }
.rec-stop:active { transform: scale(0.96); }
.rec-bar.busy .rec-dot { animation: none; opacity: 0.4; }
.rec-bar.busy .rec-stop { opacity: 0.5; pointer-events: none; }
.rec-bar:not(:has(.rec-words:not(:empty))) .rec-words { display: none; }
@media (max-width: 420px) { .rec-words { width: auto; } }

/* Voice comments */
.comment-mic { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); }
.comment-mic:hover { color: var(--fg); background: var(--hover); }
.comment-form:not(:has(textarea:placeholder-shown)) .comment-mic { display: none; }
.comment-form:has(textarea:placeholder-shown):not(.recording) .comment-send { display: none; }
.comment-form.recording textarea, .comment-form.recording .comment-mic { display: none; }
.comment-form.recording .comment-send { opacity: 1; pointer-events: auto; background: var(--danger); color: #fff; }
.comment-form.busy .comment-send { opacity: 0.5; pointer-events: none; }
.comment-rec { flex: 1; display: flex; align-items: center; gap: 8px; min-height: 30px; margin-left: -8px; }
.comment-rec .icon-btn { width: 28px; height: 28px; color: var(--muted); }
.comment-text.transcript { color: var(--muted); font-size: 13.5px; }
.comment-state { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

@media (max-width: 420px) {
  .add-item { flex-direction: column; justify-content: center; gap: 1px; height: auto; min-height: 48px; padding: 5px 10px; font-size: 11.5px; }
}

/* ---------- Important cards, and cards that are new to you ---------- */
/* A ring the same width on screen at any zoom, like the selection, so they stand out even zoomed far out. */
.item.flagged:not(svg)::before, .item.is-new:not(svg)::before {
  content: "";
  position: absolute;
  inset: calc(-4px * var(--inv));
  border-radius: calc(var(--r-card) + 4px * var(--inv));
  box-shadow: 0 0 0 calc(2px * var(--inv)) var(--ring), 0 0 calc(14px * var(--inv)) color-mix(in srgb, var(--ring) 35%, transparent);
  pointer-events: none;
}
.item.is-new { --ring: var(--accent); }
.item.flagged { --ring: var(--important); }
.item.selected::before { display: none; }
.card-tags {
  /* On the top-right corner, centered on it: it only covers the card's padding, never its text. */
  position: absolute;
  right: 0;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 3px;
  pointer-events: none;
  /* Part of the card: it scales with the board, so it never covers the text. Zoomed out, the ring shows the card instead. */
  transform: translate(calc(50% - 10px), -50%);
}
.card-tags span {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  color: #fff;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
  box-shadow: 0 0 0 1.5px var(--bg), 0 1px 3px rgba(0, 0, 0, 0.2);
}
.card-tags .tag-new { padding: 0 7px; }
.card-tags svg { width: 11px; height: 11px; }
.card-tags .tag-important { background: var(--important); }
.card-tags .tag-new { background: var(--accent); }
.item-tools .text-btn.important-on { color: var(--important); }
.item-tools .text-btn.important-on svg { fill: currentColor; }
.new-btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px 0 9px; border-radius: 15px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; }
.new-btn:hover { filter: brightness(1.08); }
.new-btn.has-important { background: var(--important); }
.new-btn svg { width: 14px; height: 14px; }
.new-read { color: var(--muted); }
.new-btn[hidden], .new-read[hidden] { display: none; }

/* ---------- Watching a video together ---------- */
.call-bar .call-watch[hidden] { display: none; }
.watch { position: fixed; inset: 0; z-index: 28; background: #000; color: #fff; animation: fade 0.2s ease; }
.watch-stage { position: absolute; inset: 0; cursor: pointer; }
/* A YouTube video (youtube.js): its frame fills the stage, and a see-through layer on top takes the clicks. */
.yt { position: relative; }
.watch-stage .yt { position: absolute; inset: 0; }
.yt-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.yt-shield { position: absolute; inset: 0; }
.link .yt-play { position: absolute; top: 12px; right: 12px; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: rgba(0, 0, 0, 0.62); color: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); transition: transform 0.15s ease, background 0.15s ease; }
.link .yt-play svg { margin-left: 2px; }
.link .yt-play:hover { background: #e5302a; transform: scale(1.06); }
.link .yt-play[hidden] { display: none; }
.watch-stage video { position: absolute; inset: 0; width: 100% !important; height: 100% !important; max-height: none; margin: 0; object-fit: contain; pointer-events: none; }
.watch button { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%; color: #fff; }
.watch button:hover { background: rgba(255, 255, 255, 0.16); }
.watch-name, .watch-close, .watch-controls { position: absolute; transition: opacity 0.3s ease; }
.watch-name { top: calc(18px + var(--safe-top)); left: calc(18px + var(--safe-left, 0px)); max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; text-shadow: 0 1px 4px #000; pointer-events: none; }
.watch .watch-close { position: absolute; top: calc(8px + var(--safe-top)); right: calc(8px + var(--safe-right)); background: rgba(0, 0, 0, 0.45); }
.watch-controls { left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 10px; padding: 28px 12px calc(10px + var(--safe-bottom)); background: linear-gradient(transparent, rgba(0, 0, 0, 0.75)); }
.watch-seek { flex: 1; min-width: 0; accent-color: #fff; }
.watch-time { flex: none; font-size: 12px; font-variant-numeric: tabular-nums; }
body.watch-rest .watch-stage { cursor: none; }
body.watch-rest .watch-name, body.watch-rest .watch-close, body.watch-rest .watch-controls { opacity: 0; pointer-events: none; }

/* The people in the call: small, in the corner above the controls. */
body.watching .call-panel { left: auto !important; top: auto !important; right: calc(10px + var(--safe-right)) !important; bottom: calc(66px + var(--safe-bottom)) !important; width: auto !important; max-height: 60dvh; padding: 6px; gap: 6px; opacity: 0.7; transition: opacity 0.3s ease; }
body.watching .call-panel:hover, body.watching .call-panel:focus-within { opacity: 1; }
body.watching .call-tiles { display: flex !important; flex-wrap: wrap; justify-content: flex-end; max-width: min(300px, 70vw); cursor: default; }
body.watching .call-tile { width: 92px !important; height: auto !important; aspect-ratio: 4 / 3 !important; }
body.watching .call-avatar.avatar { font-size: 12px; }
body.watching .call-name { left: 3px; bottom: 3px; max-width: calc(100% - 6px); padding: 0 5px; font-size: 10px; }
body.watching .call-size { display: none; }
body.watch-rest .call-panel:not(:hover):not(:focus-within) { opacity: 0.45; background: transparent; box-shadow: none; border-color: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; }
body.watch-rest .call-panel:not(:hover):not(:focus-within) .call-bar { display: none; }

/* Muting someone for yourself only. */
.call-out-btn { position: absolute; z-index: 2; top: 4px; right: 4px; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: rgba(0, 0, 0, 0.55); color: #fff; cursor: pointer; transition: opacity 0.15s ease, background 0.15s ease; }
.call-out-btn:hover { background: var(--danger); }
@media (hover: hover) { .call-tile:not(:hover) .call-out-btn:not(:focus-visible) { opacity: 0; } }
.call-panel.mini .call-out-btn { display: none; }
body.watching .call-out-btn { width: 24px; height: 24px; top: 3px; right: 3px; }
.call-hush { position: absolute; z-index: 2; top: 4px; left: 4px; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: rgba(0, 0, 0, 0.55); color: #fff; cursor: pointer; transition: opacity 0.15s ease; }
.call-tile.hushed .call-hush { background: var(--danger); }
@media (hover: hover) { .call-tile:not(:hover):not(.hushed) .call-hush:not(:focus-visible) { opacity: 0; } }
.call-panel.mini .call-hush { top: auto; bottom: 1px; left: 50%; transform: translateX(-50%); width: 22px; height: 22px; }
body.watching .call-hush { width: 24px; height: 24px; top: 3px; left: 3px; }

/* ---------- Verdikt: live task cards on a board, and the board inside Verdikt ---------- */

.task.card {
  width: 260px; min-height: 104px; padding: 11px 13px 10px; display: flex; flex-direction: column; gap: 6px;
  cursor: pointer; --c: #0090ff;
  box-shadow: inset 3px 0 0 var(--c), inset 0 0 0 0.5px var(--border), var(--note-shadow);
}
.task.card[data-status="backlog"] { --c: #8e8e93; }
.task.card[data-status="progress"] { --c: #f5a524; }
.task.card[data-status="done"] { --c: #30a46c; }
.task.card.missing { opacity: 0.55; }
.vt-top { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.vt-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.task.card[data-status="backlog"] .vt-dot, .task.card[data-status="todo"] .vt-dot { background: none; box-shadow: inset 0 0 0 2px var(--c); }
.vt-key { font-weight: 650; }
.vt-type { margin-left: auto; font-weight: 550; }
.vt-title { flex: 1; font-size: 14.5px; font-weight: 550; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: var(--fg); }
.task.card[data-status="done"] .vt-title { text-decoration: line-through; color: var(--muted); }
.vt-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.vt-status { padding: 1px 8px; border-radius: 999px; font-weight: 600; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
.vt-due { color: var(--muted); }
.vt-due.late { color: var(--danger); font-weight: 600; }
.vt-who { margin-left: auto; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 10px; font-weight: 650; }
.vt-who[hidden] { display: none; }

.embedded #home-link, .embedded #share-btn { display: none; }
