.board-frame:has(> .annotation-layer) {
  position: relative;
  overflow: hidden;
}

.annotation-layer {
  display: contents;
}

.annotation-art,
.annotation-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.annotation-art {
  grid-column: 2;
  grid-row: 2;
  z-index: 4;
  overflow: visible;
  pointer-events: none;
}

.annotation-input[data-tool="eraser"] {
  cursor: cell;
}

.annotation-input {
  z-index: 5;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: transparent;
  cursor: crosshair;
  pointer-events: auto;
  touch-action: none;
}

.annotation-input:focus-visible {
  outline-offset: -2px;
}

.annotation-cursor {
  visibility: hidden;
}

.annotation-layer:has(.annotation-input:focus-visible) .annotation-cursor {
  visibility: visible;
}

.annotation-toggle[aria-pressed="true"],
.annotation-controls button[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
  background: #374a30;
}

.board-footer:has(.annotation-toggle[aria-pressed="true"]) .board-help {
  visibility: hidden;
}

.annotation-panel {
  margin-top: .5rem;
  padding: .5rem;
  border: 1px solid #465b48;
  border-radius: .55rem;
  background: #182a20;
}

.annotation-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
}

.annotation-edit-actions {
  display: flex;
  gap: .4rem;
}

.annotation-toggle,
.annotation-controls .button {
  min-height: 2.5rem;
  padding: .35rem .55rem;
  font-size: .875rem;
}

.annotation-controls .button:disabled {
  opacity: .52;
}

.annotation-color,
.annotation-thickness {
  display: flex;
  align-items: center;
  gap: .35rem;
  color: var(--muted);
  font-size: .875rem;
}

.annotation-color input {
  width: 2.55rem;
  height: 2.5rem;
  border: 1px solid #556b56;
  border-radius: .45rem;
  padding: .3rem;
  background: #0f2116;
  cursor: pointer;
}

.annotation-thickness input {
  width: 4.8rem;
  min-height: 2.5rem;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.annotation-thickness-value {
  min-width: 2ch;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.annotation-help {
  margin-top: .38rem;
  color: var(--muted);
  font-size: .875rem;
}

.page-annotation-toggle {
  min-height: 2.5rem;
  gap: .4rem;
}

.page-annotation-toggle[aria-pressed="true"],
.page-annotation-tools [aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
  background: #374a30;
}

.page-annotation-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: none;
  overflow: visible;
  background: transparent;
  color: var(--ink);
  pointer-events: none;
}

.page-annotation-layer::backdrop {
  pointer-events: none;
}

.page-annotation-art,
.page-annotation-surface {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.page-annotation-art {
  display: block;
  pointer-events: none;
}

.page-annotation-surface {
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  cursor: crosshair;
}

.page-annotation-surface[data-tool="eraser"] {
  cursor: cell;
}

.page-annotation-toolbar,
.page-annotation-floating-toggle {
  position: absolute;
  inset-inline-end: max(.75rem, env(safe-area-inset-right));
  pointer-events: auto;
  box-shadow: 0 7px 24px #060f0bc9;
}

.page-annotation-floating-toggle {
  inset-block-end: max(.75rem, env(safe-area-inset-bottom));
}

.page-annotation-toolbar {
  inset-block-end: max(.75rem, env(safe-area-inset-bottom));
  box-sizing: border-box;
  width: max-content;
  max-width: calc(100% - 1.5rem);
  max-height: calc(100% - 1.5rem);
  overflow: auto;
  padding: .65rem .7rem;
}

.page-annotation-toolbar[data-dock="top"] {
  inset-block-start: max(.75rem, env(safe-area-inset-top));
  inset-block-end: auto;
  margin-top: 0;
}

.page-annotation-toolbar .annotation-controls {
  gap: .4rem;
}

.page-annotation-options {
  margin-top: .5rem;
  padding-top: .5rem;
  border-top: 1px solid #465b48;
}

.page-annotation-options[hidden] + .annotation-help {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.page-annotation-tools,
.page-annotation-style {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .4rem;
}

.page-annotation-toolbar .annotation-controls .button {
  min-block-size: 2.75rem;
  min-inline-size: 2.75rem;
}

.page-annotation-toolbar .annotation-edit-actions {
  margin-inline-start: auto;
  flex-wrap: wrap;
}

@media (max-width: 510px) {
  .top-bar-inner {
    flex-wrap: wrap;
    gap: .5rem .65rem;
    padding-block: .5rem;
  }

  .top-bar-actions {
    flex-wrap: wrap;
    max-width: 100%;
  }

  .page-annotation-toolbar {
    padding: .45rem .38rem;
  }

  .page-annotation-toolbar .annotation-controls,
  .page-annotation-toolbar .page-annotation-tools,
  .page-annotation-toolbar .annotation-edit-actions {
    gap: .25rem;
  }

  .page-annotation-toolbar .annotation-controls .button {
    padding-inline: .4rem;
  }

  .page-annotation-toolbar .annotation-edit-actions {
    margin-inline-start: 0;
  }
}
