/* Styles for gallery, login, and viewer. Dark only: pure
   black, white at different opacities, glass surfaces and 2px solid
   white-10% borders that brighten on hover. System fonts only. */
:root {
  --bg: #000000;
  --fg: #ffffff;
  /* White at different opacities carries the hierarchy */
  --text-strong: rgb(255 255 255 / 0.9);
  --text-body: rgb(255 255 255 / 0.6);
  --muted: rgb(255 255 255 / 0.5);
  /* Borders and surfaces */
  --line: rgb(255 255 255 / 0.1);
  --line-hover: rgb(255 255 255 / 0.25);
  --glass: rgb(255 255 255 / 0.03);
  --glass-hover: rgb(255 255 255 / 0.08);
  /* Menus and dialogs sit over content, so they are nearly opaque */
  --float: rgb(10 10 10 / 0.96);
  /* The same color fully opaque: for surfaces over the artifact's own text */
  --float-solid: #0a0a0a;
  /* Behind the screens of a canvas page: black, or white when the viewer
     picks it (.canvas[data-bg="white"] below) */
  --canvas-bg: #000000;
  /* Pins on canvas screens: they sit on the author's (usually white) page */
  --pin: #2563eb;
  --pin-hover: #1d4ed8;
  --pin-resolved: #6b7280;
  --overlay: rgb(0 0 0 / 0.6);
  --danger: #ff6467;
  --public: #05df72;
  --primary: #d1d5dc;
  --primary-hover: #e5e7eb;
  --border: 2px solid var(--line);
  /* Keyboard focus: black gap, then a gray ring */
  --ring: 0 0 0 2px #000, 0 0 0 4px #99a1af;
  --font:
    system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --gutter: 16px;
  --radius: 8px;
  /* One height for every button, select and chip in the bar */
  --control: 32px;
  --panel-width: 340px;
  --ease: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  color-scheme: dark;
}
* {
  box-sizing: border-box;
}
/* Author display rules (buttons are inline-flex) must not undo the attribute */
[hidden] {
  display: none !important;
}
html,
body {
  margin: 0;
}
body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 var(--font);
  overflow-x: hidden;
}
h1 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}
code,
pre {
  font-family: var(--font-mono);
}
button,
input,
textarea,
a {
  font: inherit;
  color: inherit;
}

/* Buttons: ghost outlines on glass, one height. .primary is the one filled
   pale gray button of a view. Links styled .btn look the same. */
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control);
  padding: 0 12px;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--glass);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: var(--text-strong);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    color var(--ease),
    border-color var(--ease),
    background-color var(--ease),
    box-shadow var(--ease);
}
button:hover,
.btn:hover {
  border-color: var(--line-hover);
  color: var(--fg);
}
button:active,
.btn:active {
  background: var(--glass-hover);
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
button:focus-visible,
.btn:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.btn-icon {
  flex: none;
  width: var(--control);
  padding: 0;
}
button.primary,
.btn.primary {
  border-color: transparent;
  background: var(--primary);
  color: #000;
}
button.primary:hover,
.btn.primary:hover {
  background: var(--primary-hover);
  border-color: transparent;
  color: #000;
}
.danger {
  color: var(--danger);
}
.icon {
  flex: none;
}

/* Fields */
input,
textarea {
  padding: 8px 12px;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--glass);
  color: var(--primary);
}
input::placeholder,
textarea::placeholder {
  color: #99a1af;
}
input:hover,
textarea:hover,
input:focus-visible,
textarea:focus-visible {
  border-color: var(--line-hover);
}
/* Checkboxes: the real input, redrawn as a small dark box; checked fills it
   pale gray with a black check (the same pair as button.primary) */
input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  display: inline-grid;
  place-content: center;
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  border: var(--border);
  border-color: var(--line-hover);
  border-radius: 4px;
  background: var(--glass);
  cursor: pointer;
  transition:
    border-color var(--ease),
    background-color var(--ease);
}
input[type="checkbox"]::before {
  content: "";
  width: 10px;
  height: 10px;
  background: #000;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3 8.5 3.25 3.25L13 5'/%3E%3C/svg%3E")
    center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3 8.5 3.25 3.25L13 5'/%3E%3C/svg%3E")
    center / contain no-repeat;
  transform: scale(0);
  transition: transform var(--ease);
}
input[type="checkbox"]:hover,
label:hover > input[type="checkbox"] {
  border-color: rgb(255 255 255 / 0.45);
}
input[type="checkbox"]:checked {
  border-color: var(--primary);
  background: var(--primary);
}
input[type="checkbox"]:checked::before {
  transform: scale(1);
}
input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: default;
}
label {
  color: var(--text-body);
}

/* Top bar shared by gallery and viewer: one row, the title gives way first */
.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px var(--gutter);
  border-bottom: var(--border);
}
.bar-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar form {
  margin-left: auto;
}
/* A link pushed to the right ahead of the Log out form */
.bar .bar-end {
  margin-left: auto;
}
.bar .bar-end + form {
  margin-left: 0;
}
.bar h1 a {
  color: inherit;
  text-decoration: none;
}
.actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* Version button: "v3 · current ▾", long text is cut with an ellipsis */
.version-button {
  max-width: 220px;
  min-width: 0;
}
.version-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
[data-action="comments"] [data-comment-count]:not(:empty) {
  font-variant-numeric: tabular-nums;
}
/* The link button swaps its icon for a check while it says "copied" */
.swap {
  display: inline-grid;
}
.swap > * {
  grid-area: 1 / 1;
}
.swap > :last-child,
.is-done .swap > :first-child {
  visibility: hidden;
}
.is-done .swap > :last-child {
  visibility: visible;
  color: var(--public);
}
/* The page theme button shows what a click does: a sun while the page is
   dark, a moon once it is pressed (the page turned bright) */
.theme-button[aria-pressed="true"] .swap > :first-child {
  visibility: hidden;
}
.theme-button[aria-pressed="true"] .swap > :last-child {
  visibility: visible;
}

/* Visibility chip: a small pill with a lock (private), a globe (public) or a key */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
}
.chip::before {
  content: "";
  flex: none;
  width: 12px;
  height: 12px;
  background: currentColor;
  -webkit-mask: var(--chip-glyph) center / contain no-repeat;
  mask: var(--chip-glyph) center / contain no-repeat;
}
.chip-private {
  --chip-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Crect x='3' y='7' width='10' height='7' rx='1.5' fill='black' stroke='none'/%3E%3Cpath d='M5.5 7V5a2.5 2.5 0 0 1 5 0v2'/%3E%3C/svg%3E");
  background: var(--line);
  color: var(--text-body);
}
.chip-public {
  --chip-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='6.25'/%3E%3Cellipse cx='8' cy='8' rx='2.6' ry='6.25'/%3E%3Cpath d='M2 8h12'/%3E%3C/svg%3E");
  background: rgb(34 197 94 / 0.15);
  color: var(--public);
}
/* Private page with a password: a key, in amber */
.chip-password {
  --chip-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='5' cy='11' r='2.75'/%3E%3Cpath d='M7 9 13.5 2.5M11 5l2 2M9.25 6.75l1.5 1.5'/%3E%3C/svg%3E");
  background: rgb(251 191 36 / 0.15);
  color: #fbbf24;
}
/* The visitor's mode note ("View only" / "Can edit"): plain muted text
   beside the title, no pill and no icon, gone on narrow screens */
.chip-mode {
  flex: none;
  padding: 0;
  color: var(--muted);
}
.chip-mode::before {
  display: none;
}
@media (max-width: 640px) {
  .chip-mode {
    display: none;
  }
}
/* In the bar the chip is as tall as the buttons */
.actions .chip {
  height: var(--control);
  padding: 0 12px;
}

/* Shown while the owner looks at an old version */
.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0;
  padding: 8px var(--gutter);
  background: var(--glass);
  border-bottom: var(--border);
  color: var(--text-body);
}
.notice a {
  color: var(--text-strong);
  text-underline-offset: 4px;
}
/* The button keeps the normal text color, not the muted notice color */
.notice button {
  color: var(--text-strong);
}

/* Gallery: one centered column, days with full-width rows */
.gallery {
  padding: var(--gutter);
  max-width: 860px;
  margin: 0 auto;
}
.day h2 {
  margin: 24px 0 4px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.rows {
  list-style: none;
  padding: 0;
  margin: 0;
}
.rows li + li {
  border-top: var(--border);
}
.row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 8px;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background-color var(--ease);
}
.row:hover {
  background: var(--glass-hover);
}
.row-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.row-title {
  font-weight: 700;
  overflow-wrap: anywhere;
}
/* A row is a link with a ⋯ button beside it */
.row-item {
  display: flex;
  align-items: flex-start;
  gap: 4px;
}
.row-item .row {
  flex: 1 1 auto;
  min-width: 0;
  /* No text selection or iOS callout while pressing and holding */
  -webkit-touch-callout: none;
  user-select: none;
}
.row-more {
  flex: none;
  margin-top: 8px;
  width: var(--control);
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}
.row-more:hover {
  background: var(--glass-hover);
  color: var(--fg);
}
/* Short messages float over the page so showing and clearing one never moves
   the rows (a layout shift would scroll the page and close an open menu) */
/* Search box: full width above the list, with the "/" hint or a clear button inside */
.search {
  position: relative;
  margin: 8px 0 0;
}
.search input {
  width: 100%;
  padding: 12px 48px 12px 16px;
}
.search-key,
.search-clear {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
}
.search-key {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  pointer-events: none;
}
.search-note {
  margin: 12px 8px 0;
  color: var(--muted);
  font-size: 13px;
}
.search-results {
  margin-top: 8px;
}
/* Phones and tablets have no "/" key */
@media (hover: none) {
  .search-key {
    display: none;
  }
}
.gallery-status {
  position: fixed;
  left: var(--gutter);
  bottom: var(--gutter);
  z-index: 30;
  max-width: calc(100vw - 2 * var(--gutter));
  margin: 0;
  padding: 8px 12px;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--float);
  color: var(--text-strong);
  overflow-wrap: anywhere;
}
.gallery-status:empty {
  display: none;
}

/* Popup menus (row menu, ⋯ menu, version list) and the confirmation dialogs */
.menu {
  position: fixed;
  z-index: 20;
  min-width: 180px;
  max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
  padding: 4px;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--float);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.6);
}
.menu[hidden] {
  display: none;
}
.menu button {
  display: flex;
  justify-content: flex-start;
  width: 100%;
  height: auto;
  min-height: var(--control);
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  text-align: left;
  white-space: normal;
}
/* display above would otherwise win over the hidden attribute */
.menu button[hidden] {
  display: none;
}
.menu button:hover,
.menu button:focus-visible {
  background: var(--glass-hover);
}
.menu button:focus-visible {
  box-shadow: inset 0 0 0 2px #99a1af;
}
/* Version list: options are one line each and long labels are cut */
.menu-versions {
  width: max-content;
  max-width: min(420px, calc(100vw - 16px));
  max-height: min(60dvh, 420px);
}
.menu-versions button {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-body);
}
.menu-versions button[aria-selected="true"] {
  color: var(--fg);
  font-weight: 700;
}
/* Copy link and the owner's page theme switch live in the bar on wider
   screens and in the ⋯ menu on phones */
.menu-copy,
.menu-theme {
  display: none !important;
}
.confirm {
  max-width: min(420px, calc(100vw - 2 * var(--gutter)));
  padding: 20px;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--float);
  color: var(--fg);
}
.confirm::backdrop {
  background: var(--overlay);
}
.confirm p {
  margin: 0 0 16px;
  overflow-wrap: anywhere;
}
.confirm label {
  display: block;
  margin-bottom: 6px;
}
.confirm input {
  width: 100%;
  padding: 12px 16px;
}
/* Password dialog: note under the question, Generate and Copy under the field */
.dialog-note {
  color: var(--text-body);
  font-size: 13px;
}
.password-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 16px;
}
.confirm .error[hidden] {
  display: none;
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
/* A destructive confirm button: red text on a red-tinted outline */
.confirm-actions .danger {
  border-color: rgb(255 100 103 / 0.4);
}
.confirm-actions .danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}
/* The shared dialog (site-dialog.js): a bold question, then the details */
.confirm .site-dialog-title {
  color: var(--text-strong);
  font-size: 15px;
  font-weight: 700;
}
.confirm .site-dialog-title:has(+ .dialog-note:not([hidden])) {
  margin-bottom: 6px;
}
.site-dialog .error {
  margin: 8px 0 0;
}
/* Room between a text field (when asked for) and the buttons */
.site-dialog input:not([hidden]) ~ .confirm-actions {
  margin-top: 16px;
}

/* At most two lines of the description */
.row-description {
  color: var(--text-body);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
.row-meta {
  flex: none;
  display: flex;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  /* Lines up with the first line of the title */
  line-height: 1.7;
}
.empty {
  color: var(--muted);
}

/* API keys page */
.muted {
  color: var(--muted);
}
.key-new {
  margin: 16px 0;
  padding: 12px 16px;
  border: var(--border);
  border-radius: var(--radius);
}
.key-new p {
  margin: 0 0 8px;
}
.key-new code,
.key-list code {
  overflow-wrap: anywhere;
  user-select: all;
}
.key-form {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}
.key-form input {
  flex: 1 1 auto;
  min-width: 0;
}
.key-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.key-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: 10px 0;
  border-top: var(--border);
}
.key-list form {
  margin-left: auto;
}

/* Login and password prompt */
.login {
  max-width: 360px;
  margin: 15vh auto 0;
  padding: 0 var(--gutter);
}
.login form,
.login-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}
.login input {
  padding: 12px 16px;
}
.login button,
.login .btn {
  height: auto;
  min-height: 44px;
}
.error {
  color: var(--danger);
  margin: 0;
}

/* Not found: a big lowercase "artifact not found" with a few broken letters
   (pages.ts brokenHeadline). Every pose is a transform, so nothing moves the
   layout. The floor line sits under the headline; the fallen letter lies on it. */
.lost {
  --lost-floor-gap: 0.42em;
  /* Measured for the system font at line-height 1: the baseline sits this far
     down a letter's box. The floor is 0.545em below the baseline; the drop is
     a bit more, so the tipped t's curved foot touches the line. */
  --lost-baseline: 0.875em;
  --lost-floor-drop: 0.575em;
  /* The fallen t lands a little to the right, so it lies under its own gap */
  --lost-fallen-shift: 0.22em;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--gutter);
  text-align: center;
}
.lost-title {
  position: relative;
  /* One line from phones (360px) to desktop */
  font-size: clamp(32px, 8.6vw, 96px);
  font-weight: 300;
  line-height: 1;
  letter-spacing: -0.04em;
  white-space: nowrap;
  color: var(--text-strong);
  padding: 0 0.12em var(--lost-floor-gap);
}
/* The floor: a short shelf of hairline that fades out at both ends */
.lost-title::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--line-hover) 30%,
    var(--line-hover) 70%,
    transparent
  );
}
.lost-title .letter {
  display: inline-block;
}
/* Slipped a little down and askew */
.letter-slipped {
  transform: translateY(0.07em) rotate(8deg);
}
/* Hangs from its top-right corner, swaying slowly */
.letter-hanging {
  transform-origin: 88% 12%;
  transform: rotate(-13deg);
  animation: lost-sway 4.8s ease-in-out infinite alternate;
}
/* Has fallen: tipped over onto the floor, its foot on the line and the whole
   glyph above it, its slot left empty. It pivots on its foot (the baseline is
   --lost-baseline down the box; the floor is --lost-floor-drop below it). On
   load it waits in its slot, drops, lands on its foot and tips over. */
.letter-fallen {
  transform-origin: 35% var(--lost-baseline);
  /* A little dimmer than the standing letters, still clearly a t */
  opacity: 0.7;
  transform: translate(var(--lost-fallen-shift), var(--lost-floor-drop))
    rotate(-56deg);
  animation: lost-drop 1.4s 0.7s backwards;
}
@keyframes lost-sway {
  from {
    transform: rotate(-9deg);
  }
  to {
    transform: rotate(-16deg);
  }
}
@keyframes lost-drop {
  from {
    opacity: 1;
    transform: none;
    animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45);
  }
  /* Lands upright on its foot... */
  40% {
    transform: translate(var(--lost-fallen-shift), var(--lost-floor-drop))
      rotate(0deg);
    animation-timing-function: cubic-bezier(0.5, 0, 0.9, 0.5);
  }
  /* ...tips over a little too far... */
  78% {
    transform: translate(var(--lost-fallen-shift), var(--lost-floor-drop))
      rotate(-62deg);
    animation-timing-function: ease-out;
  }
  /* ...and settles */
  to {
    opacity: 0.7;
    transform: translate(var(--lost-fallen-shift), var(--lost-floor-drop))
      rotate(-56deg);
  }
}
/* Reduced motion: the broken pose stays, nothing moves */
@media (prefers-reduced-motion: reduce) {
  .letter-hanging,
  .letter-fallen {
    animation: none;
  }
}

/* Viewer: bar on top, artifact fills the rest */
body.viewer {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}
body.viewer .bar,
body.viewer .notice {
  flex: none;
}
/* The artifact and, for the owner, the comments column side by side */
.stage {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}
.frame {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  border: 0;
  /* The artifact is the author's page: it gets a plain white canvas, not our theme */
  background: #fff;
}
/* The white canvas must not show before the page has painted: with scripts on,
   the frame stays invisible (same layout) until viewer.js adds .loaded on its
   load. Without scripts nothing hides it. */
@media (scripting: enabled) {
  .frame:not(.loaded) {
    opacity: 0;
  }
  .frame.loaded {
    transition: opacity 120ms ease-out;
  }
}
@media (prefers-reduced-motion: reduce) {
  .frame.loaded {
    transition: none;
  }
}

/* Canvas pages: the screens sit on a dark surface that canvas.js pans and
   zooms (panzoom sets the transform; the screens' sizes and places are set
   with CSSOM). Each screen keeps the author's white page. */
.canvas {
  --canvas-scale: 1;
  --label-scale: 1;
  /* Labels and screen edges, readable on the chosen background */
  --canvas-label: var(--muted);
  --canvas-edge: var(--line);
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  background: var(--canvas-bg);
}
.canvas[data-bg="white"] {
  --canvas-bg: #ffffff;
  --canvas-label: #404040;
  --canvas-edge: rgb(0 0 0 / 0.18);
}
/* The background toggle: top right, clear of the toolbar at the bottom */
.canvas-bg {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  background: var(--float);
}
/* Pressed, it stays dark (the shared pressed tint is see-through) */
.canvas-bg:active {
  background: var(--float-solid);
}
.canvas-surface {
  position: absolute;
  top: 0;
  left: 0;
}
/* Panning or zooming (canvas.js markMoving): its own compositor layer, so a
   frame moves the layer instead of repainting every screen */
.canvas-surface.is-moving {
  will-change: transform;
}
.artboard {
  position: absolute;
  margin: 0;
}
/* Hidden screens on phones keep their place and keep running */
.artboard.is-off {
  visibility: hidden;
}
/* The label stays the same size on screen whatever the zoom: it is scaled by
   1/zoom, and its width is the screen's width on screen */
.artboard-label {
  position: absolute;
  left: 0;
  bottom: 100%;
  width: calc(100% * var(--canvas-scale));
  padding-bottom: 6px;
  overflow: hidden;
  color: var(--canvas-label);
  font-size: 13px;
  line-height: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform: scale(var(--label-scale));
  transform-origin: left bottom;
}
.artboard-frame {
  display: block;
  box-shadow: 0 0 0 1px var(--canvas-edge);
}
/* Space held: covers the screens so a drag over them pans the canvas */
.canvas-shield {
  position: absolute;
  inset: 0;
  z-index: 2;
  cursor: grab;
}
.canvas-shield:active {
  cursor: grabbing;
}
.canvas-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--canvas-label);
}
.canvas-tools {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--float);
}
.canvas-zoom {
  min-width: 44px;
  color: var(--text-body);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
/* Pins: round avatar markers (the author's initial, Figma style) over the
   screens and the board. A screen's layer covers that screen; the board's
   sits at the surface's corner, over the labels and arrows. Each marker is
   a zero-size spot at its tip holding a badge that keeps its size on screen
   (scaled by 1/zoom, like the labels). Not clipped: a pin on an element at
   the top edge stands above the screen (pins out of view are not drawn). */
.artboard-pins {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.board-pins {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  z-index: 2;
}
/* Comment mode: the board takes a click anywhere, and the pointer is the
   comment pin itself, white, its tip (bottom left) the hotspot; the same
   value as COMMENT_CURSOR in canvas-source.ts, which the screens use (panzoom
   sets its own cursor on the surface inline, hence !important) */
.canvas[data-mode="comment"] .canvas-surface {
  cursor:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M2 22V12a10 10 0 0 1 20 0a10 10 0 0 1-10 10z' transform='translate(0 1)' fill='%23000' fill-opacity='.25'/%3E%3Cpath d='M2 22V12a10 10 0 0 1 20 0a10 10 0 0 1-10 10z' fill='%23fff' stroke='%23000' stroke-opacity='.75' stroke-width='1.5'/%3E%3C/svg%3E")
      2 22,
    crosshair !important;
}
/* One color per author name (thread-model.js authorAvatar picks the tone);
   white text on each passes WCAG AA */
[data-avatar-tone="0"] {
  --avatar: #2563eb;
}
[data-avatar-tone="1"] {
  --avatar: #7c3aed;
}
[data-avatar-tone="2"] {
  --avatar: #db2777;
}
[data-avatar-tone="3"] {
  --avatar: #dc2626;
}
[data-avatar-tone="4"] {
  --avatar: #c2410c;
}
[data-avatar-tone="5"] {
  --avatar: #047857;
}
[data-avatar-tone="6"] {
  --avatar: #0e7490;
}
[data-avatar-tone="7"] {
  --avatar: #4f46e5;
}
.pin-spot {
  position: absolute;
  width: 0;
  height: 0;
}
.pin {
  position: absolute;
  left: 0;
  bottom: 0;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid #fff;
  /* Round, with the corner at the tip pointed */
  border-radius: 14px 14px 14px 0;
  background: var(--avatar, var(--pin));
  line-height: 1;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.35);
  pointer-events: auto;
  transform: scale(var(--label-scale));
  transform-origin: left bottom;
}
.pin:hover {
  border-color: #fff;
  background: var(--avatar, var(--pin-hover));
  filter: brightness(0.9);
}
.pin.is-resolved {
  background: var(--pin-resolved);
}
/* A pin the reader may drag elsewhere (canvas.js): grab cursor, and touch
   leaves the press to the drag instead of panning or scrolling */
.canvas:not([data-mode="edit"]) .pin.is-movable {
  cursor: grab;
  touch-action: none;
}
/* The pin while it is dragged: lifted a little, with a deeper shadow; the
   pointer shows grabbing wherever it goes (panzoom and the board set their
   own cursors inline, hence !important) */
.pin.is-dragging {
  cursor: grabbing;
  transform: scale(calc(var(--label-scale) * 1.12)) translate(2px, -4px);
  box-shadow:
    0 10px 22px rgb(0 0 0 / 0.45),
    0 3px 8px rgb(0 0 0 / 0.3);
}
.canvas.is-pin-dragging,
.canvas.is-pin-dragging * {
  cursor: grabbing !important;
}
/* The dragged pin's layer: above every other pin */
.pin-drag-layer {
  z-index: 3;
}
/* The pin being written: an empty badge with a pulse ring */
.pin.is-draft {
  box-shadow:
    0 0 0 4px rgb(37 99 235 / 0.35),
    0 2px 6px rgb(0 0 0 / 0.35);
}
/* Use / Comment: two buttons that read as one control */
.mode-switch {
  display: flex;
  flex: none;
}
.mode-button {
  gap: 6px;
  padding: 0 10px;
}
.mode-button:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
}
.mode-button:last-child {
  margin-left: -2px;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.mode-button[aria-pressed="true"] {
  position: relative;
  border-color: var(--line-hover);
  background: var(--glass-hover);
  color: var(--fg);
}
.mode-button[aria-pressed="false"] {
  color: var(--text-body);
}
/* In the panel: which screen and element a pin is on */
.pin-target {
  margin: 0;
  color: var(--text-body);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The screen picker is for phones only */
.canvas-switch {
  display: none;
  /* Never shrinks below a readable screen name */
  min-width: 104px;
  height: var(--control);
  padding: 0 8px;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--float-solid);
  color: var(--fg);
  font: inherit;
  font-size: 14px;
}

/* Owner's comments panel, and the owner's Visits panel in the same place */
.comments,
.visits {
  flex: 0 0 var(--panel-width);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px var(--gutter);
  border-left: var(--border);
  background: var(--bg);
  overflow-y: auto;
}
.comments[hidden],
.visits[hidden] {
  display: none;
}
.comments-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.comments-head h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 auto 0 0;
}
.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: color var(--ease);
}
.toggle:hover {
  color: var(--text-strong);
}
.comment-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.comment {
  padding: 10px;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--glass);
}
.comment.resolved {
  opacity: 0.6;
}
.comment-meta {
  margin: 0;
  color: var(--text-body);
  font-size: 13px;
}
/* The author's initial avatar in front of a comment's meta line */
p.comment-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.avatar {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--avatar);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}
.comment-body {
  margin: 4px 0 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.comment-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
/* The owner's whole-page comment box sits at the bottom of the panel */
.comment-form-page {
  margin-top: auto;
}
/* A panel's filter row ("Show resolved", "Show bots"): last, below the
   composer, and stuck to the panel's bottom edge while the body scrolls. It
   reaches the panel's edges (its padding is the panel's) and keeps clear of
   a phone's home bar */
.panel-foot {
  position: sticky;
  bottom: -12px;
  z-index: 1;
  display: flex;
  align-items: center;
  margin: auto calc(-1 * var(--gutter)) -12px;
  padding: 8px var(--gutter) calc(8px + env(safe-area-inset-bottom));
  border-top: var(--border);
  background: var(--bg);
}
/* Under the composer, which already took the free space */
.comment-form-page + .panel-foot {
  margin-top: 0;
}
.comment-form textarea {
  width: 100%;
  resize: vertical;
}
/* A focused comment box gets no ring, only its border a shade brighter
   (white 10% → 25%) */
.comment-form textarea:focus-visible {
  outline: none;
  box-shadow: none;
  border-color: var(--line-hover);
}
.panel-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* Inline threads: the quoted page text, replies one level under it, actions */
.comment.is-active {
  border-color: var(--line-hover);
}
.comment.is-flash {
  background: var(--glass-hover);
}
.comment.composing {
  border-color: var(--line-hover);
}
.quote {
  margin: 6px 0 0;
  padding: 2px 0 2px 8px;
  border-left: 2px solid rgb(255 190 40 / 0.7);
  color: var(--text-body);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.orphan-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.replies {
  list-style: none;
  margin: 8px 0 0;
  padding: 0 0 0 10px;
  border-left: var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.reply .comment-body {
  margin-bottom: 2px;
}
.thread-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.thread-actions button,
.form-actions button {
  height: 28px;
  padding: 0 10px;
  font-size: 13px;
}
.thread-actions + .comment-form {
  margin-top: 8px;
}
.thread-fold > summary {
  cursor: pointer;
  overflow-wrap: anywhere;
}
.thread-fold[open] > summary {
  margin-bottom: 4px;
}
.link-button {
  height: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-body);
  font-size: 13px;
  text-decoration: underline;
}
.link-button:hover {
  background: none;
  color: var(--fg);
}

/* Visits panel: three totals, then one card per visit */
.visit-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}
/* The numbers line up at the bottom when a label wraps */
.visit-summary > div {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  padding: 8px 10px;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--glass);
}
.visit-summary dt {
  color: var(--muted);
  font-size: 12px;
}
.visit-summary dd {
  margin: 0;
  color: var(--text-strong);
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.visit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.visit {
  padding: 10px;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--glass);
}
.visit-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.visit-place {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--text-strong);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.visit-time {
  flex: none;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.visit-line {
  margin: 2px 0 0;
  color: var(--text-body);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.visit-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.visit-ip {
  margin: 2px 0 0;
  color: var(--muted);
  font: 12px/1.5 var(--font-mono);
  overflow-wrap: anywhere;
}
.badge {
  padding: 0 6px;
  border-radius: 9999px;
  background: var(--line);
  color: var(--text-strong);
  font-size: 11px;
  line-height: 18px;
}
.visit-more {
  align-self: center;
  height: 28px;
  padding: 0 12px;
  font-size: 13px;
}

/* Canvas pages (Figma style): no side panel. A pin opens its thread in a
   popover next to it, and the bar's Comments button opens a dropdown of
   every thread. comments-panel.js places both (fixed, kept inside the
   window); on phones they are bottom sheets (below). */
.comments-dropdown,
.comment-popover {
  position: fixed;
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border: var(--border);
  border-radius: var(--radius);
  /* Opaque: the canvas under it must never show through */
  background: var(--float-solid);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.5);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.comments-dropdown {
  width: min(360px, calc(100vw - 16px));
  max-height: min(70dvh, 560px);
}
.comment-popover {
  z-index: 16;
  width: min(320px, calc(100vw - 16px));
  max-height: min(70dvh, 480px);
}
.comments-dropdown[hidden],
.comment-popover[hidden] {
  display: none;
}
.comments-dropdown .comments-head .toggle {
  margin-left: auto;
}
.comments-dropdown .comments-head h2 {
  margin: 0;
}
.comments-dropdown .comment-form-page {
  margin-top: 4px;
  padding-top: 8px;
  border-top: var(--border);
}
/* The dropdown's list: one row per thread */
.thread-index {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.thread-row {
  justify-content: flex-start;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  height: auto;
  padding: 8px;
  border-color: transparent;
  background: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  text-align: left;
}
.thread-row:hover {
  border-color: var(--line);
  background: var(--glass);
}
.thread-row.is-resolved {
  opacity: 0.6;
}
.thread-row-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.thread-row-line {
  color: var(--text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thread-row-where {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The popover: where the thread is and its actions, the comments, the reply box */
.popover-head {
  display: flex;
  align-items: center;
  gap: 4px;
}
.popover-title {
  flex: 1 1 auto;
  min-width: 0;
}
.popover-head .btn-icon {
  width: 28px;
  height: 28px;
  border-color: transparent;
  background: none;
}
.popover-head .btn-icon:hover {
  border-color: var(--line);
}
.popover-head [aria-pressed="true"] {
  color: var(--public);
}
.popover-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.popover-thread {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* In the popover a thread's comments are plain, not cards */
.popover-thread .comment {
  padding: 0;
  border: 0;
  background: none;
}
.popover-thread .comment.resolved {
  opacity: 1;
}
.popover-thread .comment-body {
  margin: 4px 0 0 30px;
}
.popover-thread .reply {
  padding-top: 8px;
  border-top: var(--border);
}
/* A reply's trash icon, at the end of its meta line like the header's icons */
.popover-thread .reply-delete {
  width: 28px;
  height: 28px;
  /* Taller than the meta line: the negative margins keep the line's height */
  margin: -4px 0 -4px auto;
  border-color: transparent;
  background: none;
}
.popover-thread .reply-delete:hover {
  border-color: var(--line);
}
.comment-popover .form-actions {
  justify-content: flex-end;
  margin-top: 0;
}
/* The pin whose thread is open */
.pin.is-open {
  box-shadow:
    0 0 0 3px rgb(255 255 255 / 0.45),
    0 2px 6px rgb(0 0 0 / 0.35);
}

/* The Comment button that follows a text selection in the page (placed by comments-panel.js) */
.selection-comment {
  position: fixed;
  z-index: 20;
  background: var(--float);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.4);
}
.selection-comment[hidden] {
  display: none;
}

/* Preview card over commented text in the page (placed by hover-card.js): who
   wrote it, the first lines of the comment, replies and resolved state */
.hover-card {
  position: fixed;
  z-index: 20;
  width: max-content;
  max-width: min(300px, calc(100vw - 16px));
  padding: 10px 12px;
  border: var(--border);
  border-radius: var(--radius);
  /* Opaque: the page text under the card must never show through */
  background: var(--float-solid);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.5);
  cursor: pointer;
}
.hover-card p {
  margin: 0;
  overflow-wrap: anywhere;
}
.hover-card-author {
  color: var(--text-strong);
  font-size: 13px;
  font-weight: 700;
}
.hover-card .hover-card-body {
  margin-top: 2px;
  color: var(--text-body);
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}
.hover-card .hover-card-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

/* A visitor's "Commenting as …" chip, last in the bar; a click changes the name */
.name-chip {
  min-width: 0;
  max-width: 260px;
  color: var(--text-body);
  font-size: 13px;
}
.name-chip-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.name-chip [data-name-chip-name] {
  color: var(--text-strong);
}

/* Narrow screens: the chip and time drop under the title instead of squeezing it */
@media (max-width: 520px) {
  .row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }
  .row-meta {
    margin-top: 4px;
    align-items: center;
  }
}

/* Tablets and small windows: the bar gets tighter. The version drops "current"
   and the chip keeps only its icon. */
@media (max-width: 640px) {
  .version-extra {
    display: none;
  }
  .mode-label {
    display: none;
  }
  .mode-button {
    width: var(--control);
    padding: 0;
  }
  .actions .chip {
    width: var(--control);
    padding: 0;
    justify-content: center;
    font-size: 0;
  }
  .actions .chip::before {
    width: 14px;
    height: 14px;
  }
}

/* Phones: [back] title … [version] [comments] [⋯]. The chip goes, and Copy
   link and the page theme switch move into the ⋯ menu (visitors have no ⋯
   menu: they keep the theme button). */
@media (max-width: 414px) {
  .actions .chip,
  .bar-copy,
  [data-bar] .theme-button {
    display: none;
  }
  .menu-copy,
  .menu-theme {
    display: flex !important;
  }
  /* The switch's state, next to its name */
  .menu-theme[aria-checked="true"]::after {
    content: "On";
    margin-left: auto;
    padding-left: 16px;
    color: var(--muted);
  }
  .version-button {
    max-width: 110px;
  }
  /* The name chip keeps its icon and the name */
  .name-chip-prefix {
    display: none;
  }
  .name-chip {
    max-width: 120px;
    padding: 0 10px;
  }
}

/* Small phones: the name chip keeps only its icon, so the page title has room
   (the name stays in its accessible name and tooltip) */
@media (max-width: 380px) {
  .name-chip {
    width: var(--control);
    padding: 0;
  }
  .name-chip-text {
    display: none;
  }
}

/* Phones: the panel becomes a bottom sheet over the artifact */
@media (max-width: 767px) {
  /* One screen at a time, picked here; the toolbar spans the canvas */
  .canvas-switch {
    display: block;
    flex: 1 1 auto;
  }
  .canvas-tools {
    left: 12px;
  }
  /* The picker needs the room; Fit and 100% stay */
  .canvas-tools [data-action="canvas-zoom-in"],
  .canvas-tools [data-action="canvas-zoom-out"] {
    display: none;
  }
  .comments,
  .visits,
  .comments-dropdown,
  .comment-popover {
    position: fixed;
    top: auto;
    width: auto;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 70dvh;
    border-left: 0;
    border-top: var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: 0 -8px 24px rgb(0 0 0 / 0.25);
    z-index: 10;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
  }
}

/* Edit mode (text pages): the Edit switch shows it is on like the canvas
   mode buttons; Publish and Discard appear once there are changes */
.edit-button {
  gap: 6px;
  padding: 0 10px;
}
.edit-button[aria-pressed="true"] {
  border-color: var(--line-hover);
  background: var(--glass-hover);
  color: var(--fg);
}
.publish-button,
.discard-button {
  white-space: nowrap;
}
@media (max-width: 640px) {
  .edit-button {
    width: var(--control);
    padding: 0;
  }
  /* "Publish" alone; the count stays for screen readers */
  .publish-count {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}
/* Phones: Publish says only that; Discard waits for a wider screen */
@media (max-width: 414px) {
  .discard-button {
    display: none;
  }
}

/* The canvas board (edit mode): labels and arrows sit on the panned
   surface over the screens and zoom with them. Ink follows the background. */
.canvas {
  --board-ink: #ffffff;
  /* Figma's selection blue: bright on both the black and the white board */
  --board-accent: #0d99ff;
  /* Selection outlines in screen px: hover, selected, and the gap that sets
     them just outside the element */
  --outline-hover: 1.5px;
  --outline-selected: 2px;
  --outline-gap: 2px;
  --arrow-red: #ef4444;
  --arrow-blue: #3b82f6;
  --arrow-yellow: #facc15;
  --arrow-green: #22c55e;
  --arrow-white: #ffffff;
  --arrow-black: #111111;
}
.canvas[data-bg="white"] {
  --board-ink: #111111;
}
.board-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  z-index: 1;
}
.board-arrows {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  overflow: visible;
  pointer-events: none;
}
/* Arrows, tldraw style: an open line with round caps and joins, as wide as
   the arrow's size (data-size: s 2, m 3.5, l 5 board px, arrow-geometry.js
   ARROW_SIZES), with heads stroked the same way (a chevron is two strokes,
   a triangle and a dot are also filled). Red unless the arrow has its own
   color (data-color, one of board-model.js ARROW_COLORS); the shades read on
   both the black and the white board. */
.board-arrow {
  --arrow: var(--arrow-red);
  --arrow-width: 3.5px;
}
.board-arrow[data-size="s"] {
  --arrow-width: 2px;
}
.board-arrow[data-size="l"] {
  --arrow-width: 5px;
}
.board-arrow[data-color="blue"] {
  --arrow: var(--arrow-blue);
}
.board-arrow[data-color="yellow"] {
  --arrow: var(--arrow-yellow);
}
.board-arrow[data-color="green"] {
  --arrow: var(--arrow-green);
}
.board-arrow[data-color="white"] {
  --arrow: var(--arrow-white);
}
.board-arrow[data-color="black"] {
  --arrow: var(--arrow-black);
}
.board-arrow-line,
.board-arrow-head {
  fill: none;
  stroke: var(--arrow);
  stroke-width: var(--arrow-width);
  stroke-linecap: round;
  stroke-linejoin: round;
}
.board-arrow-head[data-head="triangle"],
.board-arrow-head[data-head="dot"] {
  fill: var(--arrow);
}
/* A wide clear path makes an arrow easy to pick, in Use and Edit mode, for
   readers who may change the page (never in Comment mode: a click there
   pins a comment) */
.board-arrow-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 16;
}
.can-select .board-arrow-hit {
  pointer-events: stroke;
  cursor: move;
}
/* A soft wide glow in the accent under the path (tldraw style): shown while
   hovered or selected (see "Board elements" below) */
.board-arrow-glow {
  fill: none;
  stroke: var(--board-accent);
  stroke-width: calc(var(--arrow-width) + 4px);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-opacity: 0.3;
  visibility: hidden;
}
.board-text {
  position: absolute;
  /* The layer is 0 wide: size to the text, wrap only past the max. The max
     is 640px up to a 96px text size; above that it grows with the text
     (6.6667em = 640px at 96px), so a label scaled up to 400px keeps its
     line breaks instead of wrapping a letter per line */
  width: max-content;
  max-width: max(640px, 6.6667em);
  padding: 2px 4px;
  border-radius: 4px;
  color: var(--board-ink);
  font-weight: 600;
  line-height: 1.25;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  pointer-events: none;
}
.can-select .board-text {
  pointer-events: auto;
  cursor: move;
}
/* Board elements (screens, labels, arrows) share one look, Figma style, for
   readers who may select: a bright blue outline just outside the element,
   --outline-hover wide on hover and --outline-selected once selected. Sizes
   are screen px at any zoom (--label-scale = 1/zoom). No hover while
   something is dragged. */
.can-select:not(.is-board-dragging) .board-text:not(.is-selected):hover,
.can-select:not(.is-board-dragging)
  .artboard:not(.is-selected):not(.is-active-screen):hover
  .artboard-frame {
  outline: calc(var(--outline-hover) * var(--label-scale)) solid
    var(--board-accent);
  outline-offset: calc(var(--outline-gap) * var(--label-scale));
}
/* The active screen (Use mode: the last screen pressed): its wheel scrolls
   its own page; the selection outline says so */
.artboard.is-active-screen .artboard-frame,
.board-text.is-selected,
.artboard.is-selected .artboard-frame {
  outline: calc(var(--outline-selected) * var(--label-scale)) solid
    var(--board-accent);
  outline-offset: calc(var(--outline-gap) * var(--label-scale));
}
.can-select:not(.is-board-dragging) .board-arrow:hover .board-arrow-glow {
  visibility: visible;
}
.board-arrow.is-selected .board-arrow-glow {
  visibility: visible;
  stroke-opacity: 0.45;
}
.board-text-editor {
  position: absolute;
  width: 320px;
  padding: 2px 4px;
  border: 2px solid var(--board-accent);
  border-radius: 4px;
  background: var(--float-solid);
  color: var(--fg);
  font: inherit;
  font-weight: 600;
  line-height: 1.25;
  resize: none;
}
/* In Edit mode each screen is covered: a drag moves the screen */
.board-cover {
  position: absolute;
  inset: 0;
  z-index: 1;
  cursor: move;
}
.can-select .artboard-label {
  cursor: move;
}
/* A screen's edge ring (canvas-board.js): 6 screen px just outside its frame,
   for readers who may select. Behind the frame (z-index -1), so only the
   ring takes the pointer and the page inside stays clickable; hovering it
   is hovering the screen. */
.board-edge {
  display: none;
  position: absolute;
  inset: calc(-6px * var(--label-scale));
  z-index: -1;
  cursor: move;
}
.can-select .board-edge {
  display: block;
}
/* The box around a selection of several things, 1 screen px at any zoom,
   right on their edges, where Moveable's handles sit */
.board-selection-box {
  position: absolute;
  outline: calc(1px * var(--label-scale)) solid var(--board-accent);
  pointer-events: none;
}
/* While the board drags something the screens' pages let the pointer pass */
.is-board-dragging .artboard-frame {
  pointer-events: none;
}
.board-selection-box[hidden] {
  display: none;
}
/* A selected arrow's handles, tldraw style: round, white with an accent
   ring, the same size at any zoom. canvas-board.js pushes an end's handle
   past a tip with a head (--handle-dx/--handle-dy, screen px) so the head
   stays in sight. The bend handle in the middle is smaller and hollow. */
.board-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border: 1.5px solid var(--board-accent);
  border-radius: 50%;
  background: #ffffff;
  cursor: grab;
  transform: scale(var(--label-scale))
    translate(var(--handle-dx, 0px), var(--handle-dy, 0px));
}
.board-handle-bend {
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  cursor: pointer;
}
/* Moveable's handles (board-transform.js; its own CSS is
   moveable-0.53.0.css, these win by the extra .canvas): the board's accent,
   Figma's small white squares on the corners and edges, which resize. Its
   box line is hidden: a lone screen's or label's selected outline, or the
   selection box around several things, shows instead. A group's area lets the pointer through, so a screen's
   page inside the group's box stays clickable (a press on a picked thing
   drags the group). Just outside each corner is the zone that turns it,
   with the rotate cursor (an inline SVG, turned to face its corner); edges
   have none. */
.canvas .board-moveable {
  --moveable-color: var(--board-accent);
}
.canvas .board-moveable .moveable-control {
  width: 8px;
  height: 8px;
  margin-top: -4px;
  margin-left: -4px;
  border: 1px solid var(--board-accent);
  border-radius: 1px;
  background: #ffffff;
}
.canvas .board-moveable .moveable-line.moveable-direction {
  display: none;
}
.canvas .board-moveable .moveable-area {
  pointer-events: none;
}
.canvas
  .board-moveable
  .moveable-around-control:is(
    [data-direction="n"],
    [data-direction="s"],
    [data-direction="e"],
    [data-direction="w"]
  ) {
  display: none;
}
.canvas .board-moveable .moveable-around-control[data-direction="nw"] {
  cursor:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17V11a4 4 0 0 1 4-4h6M4.5 14.5 7 17l2.5-2.5M14.5 4.5 17 7l-2.5 2.5' stroke='%23fff' stroke-width='4'/%3E%3Cpath d='M7 17V11a4 4 0 0 1 4-4h6M4.5 14.5 7 17l2.5-2.5M14.5 4.5 17 7l-2.5 2.5' stroke='%23000' stroke-width='1.6'/%3E%3C/g%3E%3C/svg%3E")
      12 12,
    alias;
}
.canvas .board-moveable .moveable-around-control[data-direction="ne"] {
  cursor:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke-linecap='round' stroke-linejoin='round' transform='rotate(90 12 12)'%3E%3Cpath d='M7 17V11a4 4 0 0 1 4-4h6M4.5 14.5 7 17l2.5-2.5M14.5 4.5 17 7l-2.5 2.5' stroke='%23fff' stroke-width='4'/%3E%3Cpath d='M7 17V11a4 4 0 0 1 4-4h6M4.5 14.5 7 17l2.5-2.5M14.5 4.5 17 7l-2.5 2.5' stroke='%23000' stroke-width='1.6'/%3E%3C/g%3E%3C/svg%3E")
      12 12,
    alias;
}
.canvas .board-moveable .moveable-around-control[data-direction="se"] {
  cursor:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke-linecap='round' stroke-linejoin='round' transform='rotate(180 12 12)'%3E%3Cpath d='M7 17V11a4 4 0 0 1 4-4h6M4.5 14.5 7 17l2.5-2.5M14.5 4.5 17 7l-2.5 2.5' stroke='%23fff' stroke-width='4'/%3E%3Cpath d='M7 17V11a4 4 0 0 1 4-4h6M4.5 14.5 7 17l2.5-2.5M14.5 4.5 17 7l-2.5 2.5' stroke='%23000' stroke-width='1.6'/%3E%3C/g%3E%3C/svg%3E")
      12 12,
    alias;
}
.canvas .board-moveable .moveable-around-control[data-direction="sw"] {
  cursor:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke-linecap='round' stroke-linejoin='round' transform='rotate(270 12 12)'%3E%3Cpath d='M7 17V11a4 4 0 0 1 4-4h6M4.5 14.5 7 17l2.5-2.5M14.5 4.5 17 7l-2.5 2.5' stroke='%23fff' stroke-width='4'/%3E%3Cpath d='M7 17V11a4 4 0 0 1 4-4h6M4.5 14.5 7 17l2.5-2.5M14.5 4.5 17 7l-2.5 2.5' stroke='%23000' stroke-width='1.6'/%3E%3C/g%3E%3C/svg%3E")
      12 12,
    alias;
}
/* Selecto's drag box: the board's accent, a pale fill */
.canvas .board-selecto {
  border: 1px solid var(--board-accent);
  background: color-mix(in srgb, var(--board-accent) 12%, transparent);
}
/* A lone screen's or label's size while it is resized, under it, the same
   size at any zoom */
.board-size {
  position: absolute;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--board-accent);
  color: #ffffff;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 16px;
  white-space: nowrap;
  pointer-events: none;
  transform-origin: 0 0;
  transform: scale(var(--label-scale)) translate(-50%, 8px);
}
.board-size[hidden] {
  display: none;
}
/* The selected arrow's toolbar: above its outline, the same size at any zoom */
.board-arrow-toolbar {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: var(--border);
  border-radius: 8px;
  background: var(--float-solid);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.3);
  transform-origin: 0 0;
  transform: scale(var(--label-scale)) translate(-50%, calc(-100% - 8px));
  white-space: nowrap;
}
/* No room above the selection: under it instead, or pinned to the canvas's
   top edge (canvas-board.js placeToolbar sets data-side) */
.board-arrow-toolbar[data-side="below"] {
  transform: scale(var(--label-scale)) translate(-50%, 8px);
}
.board-arrow-toolbar[data-side="pinned"] {
  transform: scale(var(--label-scale)) translate(-50%, 0);
}
.board-arrow-toolbar[hidden] {
  display: none;
}
.arrow-swatch {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgb(127 127 127 / 0.5);
  cursor: pointer;
}
.arrow-swatch[aria-pressed="true"] {
  outline: 2px solid var(--board-accent);
  outline-offset: 1px;
}
.arrow-swatch[data-arrow-color="red"] {
  --swatch: var(--arrow-red);
}
.arrow-swatch[data-arrow-color="blue"] {
  --swatch: var(--arrow-blue);
}
.arrow-swatch[data-arrow-color="yellow"] {
  --swatch: var(--arrow-yellow);
}
.arrow-swatch[data-arrow-color="green"] {
  --swatch: var(--arrow-green);
}
.arrow-swatch[data-arrow-color="white"] {
  --swatch: var(--arrow-white);
}
.arrow-swatch[data-arrow-color="black"] {
  --swatch: var(--arrow-black);
}
.arrow-delete {
  margin-left: 2px;
}
/* The toolbar's groups (colors, size, heads and actions), a thin divider
   between them */
.arrow-toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.arrow-toolbar-group + .arrow-toolbar-group {
  padding-left: 4px;
  border-left: 1px solid var(--line);
}
/* Size buttons: S, M, L as small letters, pressed like a segmented control */
.arrow-size {
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-body);
  font-size: 12px;
  font-weight: 600;
}
.arrow-size:hover {
  background: var(--glass-hover);
}
.arrow-size[aria-pressed="true"] {
  background: var(--glass-hover);
  color: var(--fg);
  box-shadow: inset 0 0 0 1.5px var(--board-accent);
}
/* The start head's button shows the head mirrored, pointing left */
[data-arrow-head-side="start"] .arrow-head-icon {
  transform: scaleX(-1);
}
.arrow-head-icon {
  display: inline-flex;
}
.arrow-head-icon[hidden] {
  display: none;
}
.board-arrow-toolbar button:disabled {
  opacity: 0.4;
  cursor: default;
}
/* The head menu: an icon and a name per head, the current one marked */
.menu-heads {
  min-width: 140px;
}
.menu-heads button {
  align-items: center;
  gap: 8px;
}
.menu-heads button[aria-selected="true"] {
  color: var(--fg);
  font-weight: 700;
  box-shadow: inset 0 0 0 1.5px var(--board-accent);
}
.board-tools {
  display: flex;
  gap: 6px;
  padding-right: 6px;
  border-right: var(--border);
}
.board-tools [aria-pressed="true"] {
  border-color: var(--line-hover);
  background: var(--glass-hover);
  color: var(--fg);
}
.canvas[data-tool="text"],
.canvas[data-tool="text"] .board-cover {
  cursor: text;
}
.canvas[data-tool="arrow"],
.canvas[data-tool="arrow"] .board-cover {
  cursor: crosshair;
}
/* Three mode buttons: the middle one joins both neighbours */
.mode-button:not(:first-child):not(:last-child) {
  margin-left: -2px;
  border-radius: 0;
}

/* Phones while the board is edited: the board tools need the room, so the
   zoom level steps aside (Fit stays) */
@media (max-width: 767px) {
  .canvas.is-editing .canvas-zoom {
    display: none;
  }
}
/* Phones: the arrow toolbar is too wide for one row, so its groups wrap
   into two (colors, then size, heads, Straighten and Delete) */
@media (max-width: 767px) {
  .board-arrow-toolbar {
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 6px;
    width: 256px;
  }
  .arrow-toolbar-group:nth-child(2) {
    padding-left: 0;
    border-left: 0;
  }
}
