:root {
  --mdg-focus: var(--vscode-focusBorder, #0078d4);
  --mdg-select: var(--vscode-focusBorder, #0078d4);
  --mdg-guide: var(--vscode-editorInfo-foreground, #e0398c);
  --mdg-grid: color-mix(in srgb, var(--vscode-editor-foreground, #888) 9%, transparent);
  --mdg-grid-strong: color-mix(in srgb, var(--vscode-editor-foreground, #888) 18%, transparent);
  --mdg-panel: var(--vscode-sideBar-background, var(--vscode-editorWidget-background, #f3f3f3));
  --mdg-border: var(--vscode-panel-border, var(--vscode-widget-border, #ccc));
  --mdg-fg: var(--vscode-foreground, #333);
  --mdg-muted: var(--vscode-descriptionForeground, #777);
  /* The outline of a split button under the pointer. */
  --mdg-split-hover: color-mix(in srgb, var(--mdg-fg) 45%, transparent);
  /*
   * Motion: every popover, menu, panel, tooltip and transient outline moves on these. Popovers open
   * over --mdg-motion and close over --mdg-motion-fast; side panels slide over --mdg-motion-slow.
   */
  --mdg-motion-fast: 120ms;
  --mdg-motion: 160ms;
  --mdg-motion-slow: 220ms;
  --mdg-ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --mdg-ease-in: cubic-bezier(0.4, 0, 1, 1);
  /* How far a popover rises from its anchor, how small it starts, and how far a panel slides. */
  --mdg-rise: 4px;
  --mdg-pop-scale: 0.98;
  --mdg-slide: 12px;
  /* The pause between the results of the icon picker as they fade in, one after the other. */
  --mdg-stagger: 12ms;
  --mdg-pop-shadow: 0 8px 28px rgba(0, 0, 0, 0.18), 0 1px 3px rgba(0, 0, 0, 0.14);
  --mdg-tip-bg: var(--vscode-editorHoverWidget-background, light-dark(#1f2328, #3a3f47));
  --mdg-tip-fg: var(--vscode-editorHoverWidget-foreground, #f3f4f6);
  --mdg-tip-border: var(--vscode-editorHoverWidget-border, rgba(255, 255, 255, 0.08));
}

/* The system asks for less motion: nothing moves, nothing fades. */
@media (prefers-reduced-motion: reduce) {
  :root {
    --mdg-motion-fast: 0ms;
    --mdg-motion: 0ms;
    --mdg-motion-slow: 0ms;
    --mdg-rise: 0px;
    --mdg-pop-scale: 1;
    --mdg-slide: 0px;
    --mdg-stagger: 0ms;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  color: var(--mdg-fg);
  background: var(--vscode-editor-background, #fff);
  font-family: var(--vscode-font-family, system-ui, sans-serif);
  font-size: var(--vscode-font-size, 13px);
}

#app {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
  user-select: none;
}

/* Toolbar ---------------------------------------------------------------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 3px 6px;
  border-bottom: 1px solid var(--mdg-border);
  background: var(--mdg-panel);
}

.toolbar .separator {
  width: 1px;
  height: 18px;
  margin: 0 4px;
  background: var(--mdg-border);
}

.toolbar button,
.toolbar select,
.panel button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  min-width: 24px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.toolbar select {
  border-color: var(--vscode-dropdown-border, var(--mdg-border));
  background: var(--vscode-dropdown-background, transparent);
  color: var(--vscode-dropdown-foreground, inherit);
}

.toolbar button:hover {
  background: var(--vscode-toolbar-hoverBackground, rgba(128, 128, 128, 0.15));
}

.toolbar button[aria-pressed="true"] {
  background: var(--vscode-toolbar-activeBackground, rgba(128, 128, 128, 0.25));
  border-color: var(--mdg-border);
}

/* A tool that has nothing to act on (Tag and Activate without a message or participant). */
.toolbar button:disabled {
  opacity: 0.4;
  cursor: default;
}

.toolbar button:disabled:hover {
  background: transparent;
}

.toolbar svg {
  width: 16px;
  height: 16px;
}

.toolbar .badge {
  margin-left: auto;
  padding: 1px 8px;
  border-radius: 9px;
  background: var(--vscode-badge-background, #ddd);
  color: var(--vscode-badge-foreground, #333);
  font-size: 11px;
}

.toolbar .badge.stale {
  background: var(--vscode-inputValidation-warningBackground, #fce4b0);
  color: var(--vscode-inputValidation-warningForeground, #333);
  cursor: pointer;
}

/*
 * Split buttons: the box or node tool and its shapes, the relation tool and its kinds of arrow.
 * One outline holds both parts and a line divides them; the arrow part is a dropdown as tall as
 * the button, with a chevron in the text's colour. Each part has its own hover and focus, and the
 * arrow part stays shaded while its menu is open. Without an arrow part (sequence diagrams) the
 * main part is a plain button.
 */
.toolbar .split:not([hidden]) {
  display: inline-flex;
  align-items: stretch;
}

.toolbar .split:has(> .split-arrow:not([hidden])) {
  height: 24px;
  border: 1px solid var(--mdg-border);
  border-radius: 4px;
}

.toolbar .split:has(> .split-arrow:not([hidden])):hover {
  border-color: var(--mdg-split-hover);
}

.toolbar .split:has(> .split-arrow:not([hidden])) > button {
  height: 22px;
  border: 0;
  border-radius: 3px 0 0 3px;
}

.toolbar .split:has(> .split-arrow:not([hidden])) > button.split-arrow {
  justify-content: center;
  width: 18px;
  min-width: 18px;
  padding: 0;
  border-left: 1px solid var(--mdg-border);
  border-radius: 0 3px 3px 0;
  color: var(--mdg-fg);
}

.toolbar button.split-arrow svg.chevron {
  width: 10px;
  height: 6px;
  transition: transform var(--mdg-motion-fast) var(--mdg-ease);
}

.toolbar button.split-arrow[aria-expanded="true"] {
  background: var(--vscode-toolbar-activeBackground, rgba(128, 128, 128, 0.3));
}

.toolbar button.split-arrow[aria-expanded="true"] svg.chevron {
  transform: rotate(180deg);
}

/* The diagram picker's companion: a diagram of a kind more in the file. */
.toolbar button.new-diagram {
  padding: 0 4px;
}

/* A file without diagrams: the tools that need a drawing are out of sight. */
.toolbar.no-diagram [data-drawing] {
  display: none !important;
}

/* The story picker's companion: a story of the diagram shown, or of the story playing. */
.toolbar button.new-story {
  padding: 0 4px;
}

.toolbar.no-diagram:not(.story-mode) button.new-story {
  display: none !important;
}

/* Main area -------------------------------------------------------------- */

.main {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  min-height: 0;
}

/* The side column: the layers and libraries panels, left of the stage. */
.side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-width: 300px;
}

.side .panel {
  border-left: none;
  border-right: 1px solid var(--mdg-border);
  flex: 1 1 auto;
  min-height: 0;
}

.side .panel + .panel {
  border-top: 1px solid var(--mdg-border);
}

/* The element libraries panel. */
.panel.library input[type="search"] {
  width: 100%;
  margin: 6px 0 8px;
}

.library-section h3 {
  margin: 10px 0 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mdg-muted);
}

.library-section .category {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  text-align: left;
  padding: 3px 4px;
  border-radius: 4px;
}

.library-section .category .name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-section .category .count,
.library-section .category .chevron {
  color: var(--mdg-muted);
  font-variant-numeric: tabular-nums;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 4px;
  margin: 4px 0 8px;
}

/* An element is dragged out, not its words selected. */
.panel .library-item {
  height: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 2px;
  border-radius: 6px;
  cursor: grab;
  min-width: 0;
  user-select: none;
}

.library-item:hover {
  background: color-mix(in srgb, var(--mdg-select) 10%, transparent);
}

.library-item.dragging {
  cursor: grabbing;
  opacity: 0.6;
}

.library-item .thumb {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.library-item .thumb svg {
  width: 24px;
  height: 24px;
}

.library-item .label {
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.layers-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.layers-head h2 {
  margin: 0;
}

.layer-list {
  list-style: none;
  margin: 8px 0;
  padding: 0;
}

.layer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 2px;
  border-radius: 4px;
}

.layer:hover {
  background: color-mix(in srgb, var(--mdg-select) 8%, transparent);
}

.layer.hidden .name {
  color: var(--mdg-muted);
  text-decoration: line-through;
}

.layer .name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer input {
  flex: 1 1 auto;
  min-width: 0;
}

.layer .count {
  color: var(--mdg-muted);
  font-variant-numeric: tabular-nums;
}

.layer .tools {
  display: inline-flex;
  gap: 2px;
}

.layer .tools button,
.layer .eye {
  padding: 2px;
  min-width: 0;
}

.layer .tools button[disabled] {
  opacity: 0.35;
}

.stage {
  position: relative;
  overflow: hidden;
  outline: none;
  cursor: default;
  touch-action: none;
}

/* The Pointer tool: a dot in the trail's colour, set by the app; a pan still grabs. */
.stage.pointing {
  cursor: var(--mdg-pointer-cursor, crosshair);
}

/*
 * The pen, the highlighter and the eraser: the tool's own static cursor (the pen's tip in its
 * colour and width, the eraser's circle of 16 px), over the drawing's elements too.
 */
.stage.drawing {
  cursor: var(--mdg-pointer-cursor, crosshair);
}

.stage.drawing .content [data-role] {
  cursor: inherit;
}

.stage.panning,
.stage.space {
  cursor: grab;
}

.stage.placing,
.stage.connecting {
  cursor: crosshair;
}

.stage:focus-visible {
  box-shadow: inset 0 0 0 2px var(--mdg-focus);
}

.stage.grid {
  background-image:
    linear-gradient(to right, var(--mdg-grid-strong) 1px, transparent 1px),
    linear-gradient(to bottom, var(--mdg-grid-strong) 1px, transparent 1px),
    linear-gradient(to right, var(--mdg-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--mdg-grid) 1px, transparent 1px);
}

.content {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.content > svg {
  display: block;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.18);
}

.content.stale {
  opacity: 0.45;
  filter: grayscale(0.6);
}

.content [data-role="element"],
.content [data-role="relation"],
.content [data-role="label"],
.content [data-role="lifeline"] [data-role="event"],
.content [data-role="tag"] {
  cursor: pointer;
}

.overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.overlay .outline {
  fill: none;
  stroke: var(--mdg-select);
  stroke-width: 1.5;
}

.overlay .outline.primary {
  stroke-width: 2.5;
}

.overlay .focus {
  fill: none;
  stroke: var(--mdg-focus);
  stroke-width: 2;
  stroke-dasharray: 4 3;
}

.overlay .highlight {
  fill: none;
  stroke: var(--mdg-guide);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
}

/* Where a drop goes: the group a move lands in, the shape a dragged icon is given to. */
.overlay .highlight.drop {
  fill: color-mix(in srgb, var(--mdg-select) 9%, transparent);
  stroke: var(--mdg-select);
  stroke-width: 2;
  stroke-dasharray: none;
}

/* The label an icon shape draws outside its square goes with its selection. */
.overlay .outline.label-outline {
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

/* What a placed icon will be: its picture in its square, a box beside a label, the icon alone. */
.overlay .ghost-icon {
  color: var(--mdg-fg);
}

.overlay .ghost-icon svg {
  opacity: 0.8;
}

.overlay .ghost-label {
  fill: color-mix(in srgb, var(--mdg-select) 35%, transparent);
  stroke: none;
}

.overlay .handle {
  pointer-events: all;
  fill: var(--vscode-editor-background, #fff);
  stroke: var(--mdg-select);
  stroke-width: 1.5;
}

.overlay .handle.end {
  fill: var(--mdg-select);
}

.overlay .handle.segment {
  opacity: 0.6;
}

.overlay .handle.connect {
  fill: var(--mdg-select);
  opacity: 0.75;
  cursor: crosshair;
}

/* The rotation handle, beyond the top-right corner of a selected element, and its line. */
.overlay .handle.rotate {
  cursor: grab;
  animation: mdg-fade-in var(--mdg-motion-fast) var(--mdg-ease);
}

.overlay .rotate-hit {
  fill: transparent;
  stroke: none;
}

.overlay .rotate-disc {
  fill: var(--vscode-editor-background, #fff);
  stroke: var(--mdg-select);
  stroke-width: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.14));
}

.overlay .rotate-arrow {
  fill: none;
  stroke: var(--mdg-fg);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.overlay .handle.rotate:hover .rotate-disc {
  fill: color-mix(in srgb, var(--mdg-select) 12%, var(--vscode-editor-background, #fff));
}

.overlay .rotate-line {
  stroke: var(--mdg-select);
  stroke-width: 1;
  pointer-events: none;
  animation: mdg-fade-in var(--mdg-motion-fast) var(--mdg-ease);
}

/*
 * What the pointer rests on, before it is pressed: a written activation bar, or the owner of a
 * tag's pill. A thin outline in the selection colour fades in over --mdg-motion-fast.
 */
.overlay .hover-outline {
  fill: none;
  stroke: var(--mdg-select);
  stroke-width: 1;
  opacity: 0.55;
}

.overlay .hover-outline:not(.held) {
  animation: mdg-fade-in var(--mdg-motion-fast) var(--mdg-ease);
}

/*
 * The handles of a selected activation bar, a pill above its top and one below its bottom: they
 * fade and grow in from --mdg-pop-scale over --mdg-motion-fast as the bar is selected.
 */
.overlay .handle.bar-handle {
  cursor: ns-resize;
  transform-box: fill-box;
  transform-origin: center;
  transition:
    fill var(--mdg-motion-fast) var(--mdg-ease),
    transform var(--mdg-motion-fast) var(--mdg-ease);
}

.overlay .handle.bar-handle:not(.held) {
  animation: mdg-pop-in var(--mdg-motion-fast) var(--mdg-ease);
}

.overlay .handle.bar-handle:hover {
  fill: var(--mdg-select);
  transform: scale(1.15);
}

/*
 * The end of a bar being dragged: its handle on the boundary below the row it snaps to and a guide
 * across the lifelines there, sliding from row to row over --mdg-motion-fast; in the theme's
 * `danger` colour (--mdg-danger) while the session refuses the row.
 */
.bar-drag {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  display: none;
}

.bar-drag.shown {
  display: block;
  animation: mdg-fade-in var(--mdg-motion-fast) var(--mdg-ease);
}

.bar-drag .bar-guide {
  stroke: var(--mdg-select);
  stroke-width: 1;
  stroke-dasharray: 4 3;
  transition:
    transform var(--mdg-motion-fast) var(--mdg-ease),
    stroke var(--mdg-motion-fast) var(--mdg-ease);
}

.bar-drag .bar-handle {
  fill: var(--mdg-select);
  stroke: var(--vscode-editor-background, #fff);
  stroke-width: 1.5;
  transition:
    transform var(--mdg-motion-fast) var(--mdg-ease),
    fill var(--mdg-motion-fast) var(--mdg-ease);
}

.bar-drag[data-refused] .bar-guide {
  stroke: var(--mdg-danger, var(--vscode-errorForeground, #d1242f));
}

.bar-drag[data-refused] .bar-handle {
  fill: var(--mdg-danger, var(--vscode-errorForeground, #d1242f));
}

/*
 * An element turned by its rotation handle follows the pointer without easing (a transition here
 * would ease the SVG transform the drag writes); on the drop it eases into the written angle.
 */
.content g.turned-release {
  transition: transform var(--mdg-motion-fast) var(--mdg-ease);
}

.overlay .rotation-badge text {
  fill: currentColor;
  font: 600 11px var(--vscode-font-family, system-ui, sans-serif);
}

.overlay .guide {
  stroke: var(--mdg-guide);
  stroke-width: 1;
}

/*
 * Where a drag over a list drops: a bar in the theme's guide colour across the list from edge to
 * edge, in the gap between the children the drop goes between, then in the middle of the room the
 * live preview makes there, with a dot at each end. A halo of the background keeps it apart from
 * cards of any colour. It lies in the drawing under the dragged card, whose sides its ends show
 * beside. The canvas fades it in where it first shows and slides it from gap to gap over
 * --mdg-motion-fast with --mdg-ease (its sizes are set at the zoom, so that it keeps them).
 */
.content .mdg-insertion {
  pointer-events: none;
}

.content .mdg-insertion-halo {
  stroke: var(--vscode-editor-background, #fff);
  stroke-linecap: round;
}

.content .mdg-insertion-line {
  stroke: var(--mdg-guide);
  stroke-linecap: round;
}

.content .mdg-insertion-dot {
  fill: var(--mdg-guide);
  stroke: var(--vscode-editor-background, #fff);
}

/*
 * What is dragged over a list floats above the cards that make room for it, lifted by a shadow;
 * the cards glide to their new places (the canvas animates them over --mdg-motion-fast).
 */
.content g.mdg-depth {
  filter: drop-shadow(0 2px 3px rgba(15, 23, 42, 0.12));
}

.content g.mdg-lifted {
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.2)) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.12));
}

/*
 * The + at the end of a hovered or selected list (below a column's last child, right of a row's):
 * a round button that adds a sticky note to a column, or a column to a row. It fades and grows in
 * from --mdg-pop-scale over --mdg-motion-fast, and out the same way; hidden, it takes no press.
 */
.list-adds {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.list-add {
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--mdg-select) 55%, transparent);
  border-radius: 50%;
  background: var(--vscode-editor-background, #fff);
  color: var(--mdg-select);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.16),
    0 0 0 3px color-mix(in srgb, var(--vscode-editor-background, #fff) 60%, transparent);
  cursor: pointer;
  pointer-events: none;
  opacity: 0;
  transform: scale(var(--mdg-pop-scale));
  visibility: hidden;
  transition:
    opacity var(--mdg-motion-fast) var(--mdg-ease-in),
    transform var(--mdg-motion-fast) var(--mdg-ease),
    background-color var(--mdg-motion-fast) var(--mdg-ease),
    color var(--mdg-motion-fast) var(--mdg-ease),
    visibility 0s linear var(--mdg-motion-fast);
}

.list-add.shown {
  pointer-events: auto;
  opacity: 1;
  transform: none;
  visibility: visible;
  transition:
    opacity var(--mdg-motion-fast) var(--mdg-ease),
    transform var(--mdg-motion-fast) var(--mdg-ease),
    background-color var(--mdg-motion-fast) var(--mdg-ease),
    color var(--mdg-motion-fast) var(--mdg-ease),
    visibility 0s;
}

.list-add.shown:hover {
  background: var(--mdg-select);
  color: var(--vscode-editor-background, #fff);
  transform: scale(1.1);
}

.list-add.shown:active {
  transform: scale(0.94);
}

.list-add svg {
  width: 14px;
  height: 14px;
}

.list-add svg path {
  stroke-width: 1.8;
}

/*
 * A free line drawn with the relation tool: its ghost from the press to the pointer, with the
 * current kind's dashes and heads and a dot at each end, fading out on the release while the edit
 * is drawn. The points of a line whose handle is dragged follow the pointer without hit tests.
 */
.overlay .line-ghost {
  pointer-events: none;
  animation: mdg-fade-in var(--mdg-motion-fast) var(--mdg-ease);
}

.overlay .line-ghost.fading {
  animation: mdg-fade-out var(--mdg-motion) var(--mdg-ease-in) forwards;
}

.overlay .line-ghost-stroke {
  stroke: var(--mdg-select);
  stroke-width: 2;
  stroke-linecap: round;
}

.overlay .line-ghost-stroke.dashed {
  stroke-dasharray: 6 4;
}

.overlay .line-ghost-head {
  fill: var(--mdg-select);
}

.overlay .line-ghost-end {
  fill: var(--vscode-editor-background, #fff);
  stroke: var(--mdg-select);
  stroke-width: 1.5;
}

.overlay .handle.line-point {
  pointer-events: none;
}

/*
 * A stroke of the pen or the highlighter while it is drawn, and after its release until its pen is
 * drawn: the path the layout will draw, in the tool's colour, width and opacity. Ink is where the
 * hand is: it never transitions or fades in.
 */
.overlay .pen-stroke {
  pointer-events: none;
  transition: none;
  animation: none;
}

/*
 * A selected stroke scaled by a resize handle: its path as the drop will write it, a hairline in
 * the selection's colour that keeps its width at any zoom. It is where the pointer is, at every
 * frame, so it never transitions; the live preview draws the stroke itself under it.
 */
.overlay .pen-outline {
  fill: none;
  stroke: var(--mdg-select);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

/*
 * Strokes the eraser crosses fade out at once and stay hidden until its edit is drawn; Escape fades
 * them back in. Opacity in CSS outranks a stroke's own `opacity`, which comes back with the class.
 */
.content .mdg-erased {
  opacity: 0;
  transition: opacity var(--mdg-motion-fast) var(--mdg-ease-in);
}

.content .mdg-unerased {
  animation: mdg-fade-in var(--mdg-motion-fast) var(--mdg-ease);
}

.overlay .band {
  fill: color-mix(in srgb, var(--mdg-select) 12%, transparent);
  stroke: var(--mdg-select);
  stroke-width: 1;
}

.overlay .ghost {
  fill: color-mix(in srgb, var(--mdg-select) 15%, transparent);
  stroke: var(--mdg-select);
  stroke-dasharray: 4 3;
}

.overlay .wire {
  stroke: var(--mdg-select);
  stroke-width: 1.5;
  stroke-dasharray: 5 3;
}

/* The points a dragged connector end snaps to, and the one it takes. */
.overlay .anchor {
  fill: var(--vscode-editor-background, #fff);
  stroke: var(--mdg-guide);
  stroke-width: 1.5;
  pointer-events: none;
}

.overlay .anchor.active {
  fill: var(--mdg-select);
  stroke: var(--mdg-select);
}

/*
 * Other people's selections (`live-collaboration`): above the scene and below the selection's
 * overlay, never hit-tested (a press goes through to what lies under it) and never exported.
 */
.presence,
.presence * {
  pointer-events: none;
}

.presence {
  position: absolute;
  inset: 0;
  overflow: hidden;
  user-select: none;
}

.presence-outlines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* The Pointer trails: strokes drawn on a canvas, never exported and never hit. */
.presence-trails {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.presence-outline {
  fill: none;
}

.presence-tag {
  position: absolute;
  box-sizing: border-box;
  padding: 0 6px;
  overflow: hidden;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  unicode-bidi: isolate;
  box-shadow: 0 0 0 1px rgba(127, 127, 127, 0.35);
}

/*
 * Other people's pointers: an arrow in the person's colour, its tip on the point their pointer is
 * over at every zoom, and the name at its tail. Four positions a second glide into one another
 * (200 ms, linear, so that a moving pointer reads as one motion); a new cursor fades in.
 */
.presence-cursors {
  position: absolute;
  inset: 0;
}

.presence-cursor {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
  animation: mdg-cursor-in var(--mdg-motion) var(--mdg-ease);
}

.presence-cursor.gliding {
  transition: transform var(--mdg-cursor-glide, 200ms) linear;
}

.presence-cursor-arrow {
  display: block;
  overflow: visible;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.35));
}

.presence-cursor-arrow path {
  fill: var(--presence-colour, #6b7280);
  stroke: #ffffff;
  stroke-width: 1.25;
  stroke-linejoin: round;
}

.presence-cursor-tag {
  position: absolute;
  left: 12px;
  top: 17px;
  box-sizing: border-box;
  height: 18px;
  padding: 0 6px;
  overflow: hidden;
  border-radius: 3px 9px 9px 9px;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
  text-overflow: ellipsis;
  unicode-bidi: isolate;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

@keyframes mdg-cursor-in {
  from {
    opacity: 0;
    scale: 0.8;
  }
}

@media (prefers-reduced-motion: reduce) {
  .presence-cursor {
    animation: none;
  }

  .presence-cursor.gliding {
    transition: none;
  }
}

/* Messages --------------------------------------------------------------- */

.empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  color: var(--mdg-muted);
  text-align: center;
  white-space: pre-line;
}

.empty .empty-message {
  margin: 0;
}

/* A file without diagrams: a button for each kind of diagram the canvas creates. */
.empty .empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.empty .empty-actions button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--vscode-button-border, var(--mdg-border));
  border-radius: 4px;
  background: var(--vscode-button-secondaryBackground, var(--mdg-panel));
  color: var(--vscode-button-secondaryForeground, var(--mdg-fg));
  font: inherit;
  cursor: pointer;
}

.empty .empty-actions button:hover {
  background: var(
    --vscode-button-secondaryHoverBackground,
    color-mix(in srgb, var(--mdg-fg) 10%, var(--mdg-panel))
  );
}

.empty .empty-actions button:focus-visible {
  outline: 2px solid var(--mdg-focus);
  outline-offset: 1px;
}

.empty .empty-actions svg {
  flex: none;
}

.status {
  position: absolute;
  left: 8px;
  bottom: 8px;
  max-width: 70%;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--vscode-editorWidget-background, #f3f3f3);
  border: 1px solid var(--mdg-border);
  font-size: 12px;
  pointer-events: none;
}

.status:empty {
  display: none;
}

.status.error {
  border-color: var(--vscode-inputValidation-errorBorder, #be1100);
}

.banner {
  position: absolute;
  left: 50%;
  top: 8px;
  transform: translateX(-50%);
  max-width: 90%;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--vscode-inputValidation-warningBackground, #fce4b0);
  border: 1px solid var(--vscode-inputValidation-warningBorder, #b89500);
  color: var(--vscode-inputValidation-warningForeground, inherit);
  font-size: 12px;
}

.banner[hidden],
.empty[hidden],
.toolbar [hidden] {
  display: none;
}

/* Inline editor ---------------------------------------------------------- */

/*
 * The text typed where it is drawn: no frame, no background, the drawing's font, size, weight,
 * colour and alignment set by the canvas; a thin line in the selection colour marks it.
 */
.inline {
  position: absolute;
  z-index: 5;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  outline: 1px solid var(--mdg-select);
  outline-offset: 2px;
  resize: none;
  overflow: hidden;
  white-space: pre;
  overflow-wrap: normal;
  letter-spacing: normal;
  font-kerning: normal;
  font-style: normal;
  user-select: text;
  -webkit-user-select: text;
}

.inline:focus,
.inline:focus-visible {
  outline: 1px solid var(--mdg-select);
  outline-offset: 2px;
}

/* A sticky note's editor: as wide as the card's words, it breaks its lines where the drawing does
   and a word longer than the card at the card's edge. */
.inline.wrapping {
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

/*
 * A sequence message's label pulled narrower than its line: exactly as wide as the room between
 * its lifelines, it wraps there, keeps its first line where the drawing's is and grows down with
 * each line at once (no transition: the text stays where the caret is). A soft backdrop of the
 * drawing's own background (the theme's `background`, set by the canvas as --mdg-paper) keeps the
 * lines legible over the arrow and the rows they grow over until the commit redraws.
 */
.inline.growing {
  --mdg-backdrop: color-mix(
    in srgb,
    var(--mdg-paper, var(--vscode-editor-background, #fff)) 85%,
    transparent
  );
  background: var(--mdg-backdrop);
  box-shadow: 0 0 0 2px var(--mdg-backdrop);
}

/* The drawn text an open editor types over. */
.content .mdg-editing {
  visibility: hidden;
}

/* Inspector -------------------------------------------------------------- */

.panel {
  width: 260px;
  overflow-y: auto;
  border-left: 1px solid var(--mdg-border);
  background: var(--mdg-panel);
  padding: 8px 10px 16px;
  user-select: text;
}

.panel[hidden] {
  display: none;
}

/* The five property categories fit the inspector, with native overflow at large text sizes. */
.property-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  margin: 0 -4px 12px;
  padding: 2px 4px 5px;
  border-bottom: 1px solid var(--mdg-border);
}

.property-tabs [role="tab"] {
  flex: 1 0 auto;
  padding: 6px 4px;
  border: 0;
  border-radius: 5px;
  color: var(--mdg-muted);
  background: transparent;
  font-size: 11px;
  cursor: pointer;
}

.property-tabs [role="tab"][aria-selected="true"] {
  color: var(--mdg-focus);
  background: color-mix(in srgb, var(--mdg-focus) 12%, transparent);
  font-weight: 600;
}

.property-tabs [role="tab"]:focus-visible {
  outline: 2px solid var(--mdg-focus);
  outline-offset: -2px;
}

.property-panel[hidden] {
  display: none;
}

/* A panel's head: its title, then its buttons (the fold, the theme panel's Done). */
.panel .panel-head {
  display: flex;
  align-items: center;
  gap: 4px;
}

.panel .panel-head h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
}

.inspector > .panel-head {
  margin-bottom: 8px;
}

.panel button.fold svg {
  width: 16px;
  height: 16px;
}

/* Folded, the properties are a 36 px rail holding the button that unfolds them: the width moves,
   the contents fade out, then the rail fades in, as the playground's code pane folds. */
.inspector {
  position: relative;
  transition: width var(--mdg-motion-slow) var(--mdg-ease);
}

.inspector[data-collapsed="true"] {
  width: 36px;
  padding: 0;
  overflow: hidden;
}

.inspector > :not(.inspector-rail) {
  transition: opacity var(--mdg-motion-fast) var(--mdg-ease);
}

.inspector[data-collapsed="true"] > :not(.inspector-rail) {
  visibility: hidden;
  opacity: 0;
  transition:
    opacity var(--mdg-motion-fast) var(--mdg-ease),
    visibility 0s linear var(--mdg-motion-fast);
}

.inspector-rail {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 8px;
  visibility: hidden;
  opacity: 0;
  transition: opacity var(--mdg-motion-fast) var(--mdg-ease);
}

.inspector[data-collapsed="true"] .inspector-rail {
  visibility: visible;
  opacity: 1;
  transition: opacity var(--mdg-motion) var(--mdg-ease) var(--mdg-motion-fast);
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mdg-muted);
}

.panel .field {
  display: grid;
  gap: 2px;
  margin-bottom: 8px;
}

.panel label {
  font-size: 12px;
  color: var(--mdg-muted);
}

.panel input,
.panel select,
.panel textarea {
  width: 100%;
  padding: 3px 6px;
  border: 1px solid var(--vscode-input-border, var(--mdg-border));
  border-radius: 3px;
  background: var(--vscode-input-background, #fff);
  color: var(--vscode-input-foreground, inherit);
  font: inherit;
}

.panel textarea {
  min-height: 48px;
  resize: vertical;
}

.panel input:focus,
.panel select:focus,
.panel textarea:focus,
.toolbar button:focus-visible,
.toolbar select:focus-visible,
.menu [role="menuitem"]:focus,
:is(.dialog, .icon-dialog) button:focus-visible,
.picker input:focus {
  outline: 2px solid var(--mdg-focus);
  outline-offset: -1px;
}

.panel .swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 4px;
  border: 1px solid var(--mdg-border);
  vertical-align: middle;
}

/* Style strip ------------------------------------------------------------ */

.panel .strip {
  margin: 0 -10px 10px;
  padding: 0 10px 6px;
  border-bottom: 1px solid var(--mdg-border);
}

.panel .row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.panel .row > input:not([type="color"]),
.panel .row > select {
  flex: 1;
  min-width: 0;
}

.panel .row-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--mdg-muted);
}

.panel .row-label .value {
  flex: 1;
  min-width: 0;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--vscode-editor-font-family, monospace);
}

.panel .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  flex: 1;
}

.panel button.chip {
  width: 18px;
  height: 18px;
  min-width: 18px;
  padding: 0;
  border: 1px solid var(--mdg-border);
  border-radius: 3px;
  background: var(--chip, transparent);
}

.panel button.chip.inherit {
  width: auto;
  padding: 0 5px;
  font-size: 11px;
  background: transparent;
}

/* The six colours of paper of a sticky note's fill row: small cards with a folded corner, set
   apart from the theme's colours that follow them. */
.panel button.chip.paper {
  background: linear-gradient(
    315deg,
    color-mix(in srgb, var(--chip) 80%, #000) 0 5px,
    var(--chip) 5px
  );
}

.panel button.chip.paper + button.chip:not(.paper) {
  margin-left: 6px;
}

.panel button.chip[aria-checked="true"] {
  outline: 2px solid var(--mdg-select);
  outline-offset: 1px;
}

.panel button.chip:focus-visible,
.panel button.toggle:focus-visible,
.panel button.quick:focus-visible,
.panel button.link:focus-visible,
.panel button.choose:focus-visible,
.panel button.close:focus-visible,
.panel input[type="color"]:focus-visible {
  outline: 2px solid var(--mdg-focus);
  outline-offset: 1px;
}

.panel input[type="color"] {
  flex: none;
  width: 26px;
  height: 22px;
  padding: 1px;
  cursor: pointer;
}

.panel .effects {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* The Effects row: its name and what is on above the toggles, like a picture row. */
.panel .effects-row {
  gap: 4px;
}

.panel .effects-row .row-label {
  flex-wrap: wrap;
  row-gap: 0;
}

.panel .effects-row .row-label .value {
  flex: 1 0 auto;
  max-width: 100%;
}

/*
 * An effect's card under the Effects row: its name and speed in the header, its settings beneath.
 * The body folds by its grid row and fades; a card that appears with an effect just turned on
 * grows in from nothing.
 */
.panel .effect-card {
  margin: 4px 0 6px;
  border: 1px solid var(--mdg-border);
  border-radius: 4px;
}

.panel .card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px 2px 2px;
}

.panel button.card-head {
  display: inline-flex;
  flex: 1;
  align-items: center;
  gap: 4px;
  min-width: 0;
  height: 22px;
  padding: 0 4px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.panel button.card-head:focus-visible {
  outline: 2px solid var(--mdg-focus);
  outline-offset: -1px;
}

.panel .card-head svg {
  flex: none;
  width: 12px;
  height: 12px;
  transition: transform var(--mdg-motion-fast) var(--mdg-ease);
}

.panel .effect-card[data-open="true"] .card-head svg {
  transform: rotate(90deg);
}

.panel .card-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel .card-duration {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--mdg-muted);
}

.panel .card-duration input {
  width: 64px;
}

.panel .card-body {
  display: grid;
  grid-template-rows: 0fr;
  visibility: hidden;
  opacity: 0;
  transition:
    grid-template-rows var(--mdg-motion) var(--mdg-ease),
    opacity var(--mdg-motion-fast) var(--mdg-ease),
    visibility 0s linear var(--mdg-motion);
}

.panel .effect-card[data-open="true"] .card-body {
  grid-template-rows: 1fr;
  visibility: visible;
  opacity: 1;
  transition:
    grid-template-rows var(--mdg-motion) var(--mdg-ease),
    opacity var(--mdg-motion-fast) var(--mdg-ease) var(--mdg-motion-fast);
}

@starting-style {
  .panel .effect-card[data-grow="true"][data-open="true"] .card-body {
    grid-template-rows: 0fr;
    opacity: 0;
  }
}

.panel .card-fields {
  display: grid;
  gap: 4px;
  min-height: 0;
  padding: 0 6px;
  overflow: hidden;
}

.panel .card-fields > :last-child {
  margin-bottom: 6px;
}

.panel .card-fields .field {
  margin-bottom: 0;
}

/* A setting of a card: its name at the left, its control at the right. */
.panel .card-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  align-items: center;
  gap: 6px;
}

.panel .card-row label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/*
 * A yes-or-no field (**Activates the receiver**): the platform's checkbox with its label beside
 * it, in the field's text colour, and the reason under it when it is read-only.
 */
.panel .check-field label.check {
  display: flex;
  align-items: center;
  gap: 6px;
  color: inherit;
  cursor: pointer;
}

.panel .check-field input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--vscode-checkbox-selectBackground, var(--mdg-select));
}

.panel .check-field:has(input:disabled) label.check {
  cursor: default;
}

.panel .check-field .note {
  margin: 0 0 0 20px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--mdg-muted);
}

.panel .note code,
.panel .tag-row input.tag-text {
  font-family: var(--vscode-editor-font-family, ui-monospace, Menlo, Consolas, monospace);
}

/*
 * **Tags** of a sequence message or participant: one list under its heading, a text box per tag
 * with its Remove button, then the box that adds one at the end.
 */
.panel .tag-list {
  display: grid;
  gap: 4px;
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
}

.panel .tag-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.panel .tag-row input.tag-text {
  flex: 1;
  min-width: 0;
  font-size: 12px;
}

.panel .tag-row.tag-add input.tag-text {
  border-style: dashed;
}

.panel .tag-row.tag-add input.tag-text:focus {
  border-style: solid;
}

.panel button.toggle,
.panel button.quick,
.panel button.choose,
.panel button.close {
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--vscode-button-border, var(--mdg-border));
  border-radius: 3px;
  background: var(--vscode-button-secondaryBackground, transparent);
  color: var(--vscode-button-secondaryForeground, inherit);
}

.panel button.toggle[aria-pressed="true"] {
  background: var(--vscode-button-background, #0e639c);
  color: var(--vscode-button-foreground, #fff);
}

.panel button.toggle[aria-pressed="mixed"] {
  background: repeating-linear-gradient(
    135deg,
    transparent 0 4px,
    color-mix(in srgb, var(--mdg-select) 25%, transparent) 4px 8px
  );
}

.panel button[disabled] {
  opacity: 0.5;
  cursor: default;
}

.panel .theme-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
}

.panel button.link {
  height: auto;
  min-width: 0;
  padding: 0;
  border: none;
  background: none;
  color: var(--vscode-textLink-foreground, #0066bf);
  font-size: 12px;
  cursor: pointer;
}

.panel button.link:hover {
  text-decoration: underline;
}

/* Pictures of lines, routes, corners and heads ---------------------------- */

.panel button.chip.glyph {
  width: 40px;
  min-width: 40px;
  height: 24px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--vscode-input-background, transparent);
  color: var(--mdg-fg);
}

.panel button.chip.glyph.inherit {
  width: auto;
  padding: 0 6px;
  font-size: 11px;
}

.panel .head-field {
  position: relative;
}

.panel button.head-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 72px;
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--vscode-input-border, var(--mdg-border));
  border-radius: 3px;
  background: var(--vscode-input-background, #fff);
  color: var(--mdg-fg);
  cursor: pointer;
}

.panel button.head-trigger .caret {
  font-size: 10px;
  color: var(--mdg-muted);
}

.panel button.head-trigger:focus-visible {
  outline: 2px solid var(--mdg-focus);
  outline-offset: 1px;
}

.panel .head-grid {
  position: absolute;
  z-index: 5;
  top: 100%;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, 44px);
  gap: 4px;
  margin-top: 2px;
  padding: 6px;
  border: 1px solid var(--vscode-menu-border, var(--mdg-border));
  border-radius: 6px;
  background: var(--vscode-menu-background, var(--mdg-panel));
  box-shadow: var(--mdg-pop-shadow);
}

.panel .head-grid button.chip.glyph {
  width: 44px;
}

/* "Predeterminado" is longer than a cell: the default takes a row of its own. */
.panel .head-grid button.chip.glyph.inherit:lang(es) {
  grid-column: 1 / -1;
  justify-self: start;
  width: auto;
}

/* A number with bounds: the number, then its slider (the corner radius). */
.panel .range-field .row > input[type="number"] {
  flex: none;
  width: 58px;
}

.panel input[type="range"] {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: none;
  background: transparent;
  accent-color: var(--mdg-select);
}

/* Nothing written: the slider shows, greyed, what applies. */
.panel input[type="range"].inherited {
  opacity: 0.55;
}

.panel input[type="range"]:focus-visible {
  outline: 2px solid var(--mdg-focus);
  outline-offset: 1px;
}

/* Theme panel ------------------------------------------------------------ */

.theme-panel .panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.theme-panel .panel-head h2 {
  margin: 0;
}

.theme-panel .where {
  margin: 4px 0 8px;
  font-size: 12px;
  color: var(--mdg-muted);
}

.theme-panel h3 {
  margin: 12px 0 6px;
  font-size: 12px;
  font-weight: 600;
}

.overlay .highlight.source {
  stroke: var(--mdg-select);
  stroke-width: 2;
  stroke-dasharray: none;
}

/* The relation tool's cursor badge: the kind of arrow it creates. */
.overlay .cursor-badge {
  color: var(--mdg-select);
  pointer-events: none;
}

.overlay .cursor-badge rect {
  fill: var(--vscode-editorWidget-background, #fff);
  stroke: var(--mdg-select);
  stroke-width: 1;
}

/* Minimap ---------------------------------------------------------------- */

.minimap {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 200px;
  height: 140px;
  overflow: hidden;
  border: 1px solid var(--mdg-border);
  border-radius: 4px;
  background: var(--vscode-editor-background, #fff);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.15);
  cursor: pointer;
}

.minimap[hidden] {
  display: none;
}

.minimap .map {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  pointer-events: none;
}

.minimap .frame {
  position: absolute;
  border: 2px solid var(--mdg-select);
  background: color-mix(in srgb, var(--mdg-select) 8%, transparent);
  pointer-events: none;
}

/* Menu, dialog and picker ------------------------------------------------ */

.menu,
.picker {
  position: absolute;
  z-index: 10;
  min-width: 200px;
  padding: 4px 0;
  border: 1px solid var(--vscode-menu-border, var(--mdg-border));
  border-radius: 6px;
  background: var(--vscode-menu-background, #fff);
  color: var(--vscode-menu-foreground, inherit);
  box-shadow: var(--mdg-pop-shadow);
}

/*
 * On a canvas shorter than the menu, its items scroll inside it (its height is set as it opens),
 * a soft shadow at an edge where more of them lie beyond it.
 */
.menu {
  --mdg-menu-bg: var(--vscode-menu-background, #fff);
  --mdg-menu-shade: color-mix(in srgb, var(--mdg-fg) 20%, transparent);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  background:
    linear-gradient(var(--mdg-menu-bg) 40%, transparent) top / 100% 28px no-repeat local,
    linear-gradient(transparent, var(--mdg-menu-bg) 60%) bottom / 100% 28px no-repeat local,
    radial-gradient(farthest-side at 50% 0, var(--mdg-menu-shade), transparent) top / 100% 10px
      no-repeat scroll,
    radial-gradient(farthest-side at 50% 100%, var(--mdg-menu-shade), transparent) bottom / 100%
      10px no-repeat scroll,
    var(--mdg-menu-bg);
}

:is(.dialog, .icon-dialog)[hidden] {
  display: none;
}

.menu [role="menuitem"],
.menu [role="menuitemradio"] {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 3px 12px;
  cursor: pointer;
}

.menu [role="menuitem"]:hover,
.menu [role="menuitem"]:focus,
.menu [role="menuitemradio"]:hover,
.menu [role="menuitemradio"]:focus {
  background: var(--vscode-menu-selectionBackground, #0060c0);
  color: var(--vscode-menu-selectionForeground, #fff);
}

.menu [role="menuitemradio"]:focus {
  outline: 2px solid var(--mdg-focus);
  outline-offset: -1px;
}

/* The current choice of a menu of choices, such as the kind of arrow. */
.menu [role="menuitemradio"][aria-checked="true"] {
  box-shadow: inset 3px 0 0 var(--mdg-select);
  font-weight: 600;
}

.menu .label.pictured {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* The grid of shapes ------------------------------------------------------ */

.shape-menu {
  position: absolute;
  z-index: 10;
  padding: 6px;
  border: 1px solid var(--vscode-menu-border, var(--mdg-border));
  border-radius: 8px;
  background: var(--vscode-menu-background, #fff);
  color: var(--vscode-menu-foreground, inherit);
  box-shadow: var(--mdg-pop-shadow);
}

.shape-menu .shape-filter {
  margin: 0 2px 6px;
  font-size: 11px;
  color: var(--mdg-muted);
}

.shape-menu .shape-filter.typed {
  color: inherit;
  font-family: var(--vscode-editor-font-family, monospace);
}

.shape-menu .shape-grid {
  display: grid;
  grid-template-columns: repeat(4, 76px);
  gap: 4px;
}

.shape-menu .shape-grid:focus {
  outline: none;
}

.shape-menu button.chip.shape {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  height: auto;
  padding: 4px 2px 3px;
  border: 1px solid var(--mdg-border);
  border-radius: 3px;
  background: var(--vscode-input-background, transparent);
  color: var(--mdg-fg);
  font: inherit;
  cursor: pointer;
}

.shape-menu button.chip.shape .name {
  max-width: 100%;
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shape-menu button.chip.shape:hover {
  background: var(--vscode-list-hoverBackground, rgba(128, 128, 128, 0.15));
}

.shape-menu button.chip.shape[aria-checked="true"] {
  outline: 2px solid var(--mdg-select);
  outline-offset: 1px;
}

.shape-menu button.chip.shape:focus-visible {
  outline: 2px solid var(--mdg-focus);
  outline-offset: 1px;
}

/* The pen button and its menu ------------------------------------------ */

/* The pen or the highlighter over a bar of the colour it draws in. */
.toolbar button.pen-button {
  position: relative;
}

.toolbar button.pen-button svg {
  transform: translateY(-1.5px);
}

.toolbar button.pen-button .pen-swatch {
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 2px;
  height: 3px;
  border-radius: 2px;
  box-shadow: inset 0 0 0 0.5px color-mix(in srgb, var(--mdg-fg) 35%, transparent);
  transition: background-color var(--mdg-motion-fast) var(--mdg-ease);
}

/* The sticky note button: a card of the paper it adds, which moves to a colour newly chosen. */
.toolbar button.sticky-button svg [data-paper] {
  transition: fill var(--mdg-motion-fast) var(--mdg-ease);
}

/*
 * The pen menu: Pen or Highlighter on a segmented control, the widths on another, both with a
 * highlight that slides to the choice, then the colours as round chips with a ring that slides to
 * the one chosen. It opens and closes as the other popovers do (see Motion).
 */
.pen-menu {
  position: absolute;
  z-index: 10;
  display: grid;
  gap: 10px;
  width: 256px;
  padding: 8px;
  border: 1px solid var(--vscode-menu-border, var(--mdg-border));
  border-radius: 8px;
  background: var(--vscode-menu-background, #fff);
  color: var(--vscode-menu-foreground, inherit);
  box-shadow: var(--mdg-pop-shadow);
}

.pen-menu .pen-segments {
  --segment-gap: 2px;
  position: relative;
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: var(--segment-gap);
  padding: 2px;
  border: 1px solid var(--mdg-border);
  border-radius: 6px;
}

.pen-menu .pen-tools {
  --count: 2;
}

.pen-menu .pen-widths {
  --count: 4;
}

.pen-menu .pen-segment {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  height: 28px;
  padding: 0 6px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--mdg-muted);
  font: inherit;
  cursor: pointer;
  transition:
    color var(--mdg-motion-fast) var(--mdg-ease),
    background-color var(--mdg-motion-fast) var(--mdg-ease),
    transform var(--mdg-motion-fast) var(--mdg-ease);
}

.pen-menu .pen-segment svg {
  flex: none;
  width: 16px;
  height: 16px;
}

.pen-menu .pen-width svg {
  width: 28px;
}

.pen-menu .pen-segment .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pen-menu .pen-segment .key {
  font-size: 11px;
  opacity: 0.65;
}

.pen-menu .pen-segment:hover:not(:disabled):not([aria-checked="true"]) {
  background: color-mix(in srgb, var(--mdg-select) 10%, transparent);
  color: var(--mdg-fg);
}

.pen-menu .pen-segment:active:not(:disabled) {
  transform: scale(0.97);
}

.pen-menu .pen-segment[aria-checked="true"] {
  color: var(--vscode-button-foreground, #fff);
}

/* The default width, nothing written: a dashed cell, as the inspector's defaults are. */
.pen-menu .pen-width.default:not([aria-checked="true"]) {
  outline: 1px dashed color-mix(in srgb, currentColor 45%, transparent);
  outline-offset: -3px;
}

.pen-menu .pen-segment:focus-visible {
  outline: 2px solid var(--mdg-focus);
  outline-offset: 1px;
}

.pen-menu .pen-segment:disabled {
  cursor: default;
}

/* The highlighter is always 20 wide: its widths are greyed. */
.pen-menu .pen-widths.fixed {
  opacity: 0.45;
}

.pen-menu .pen-slider {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: calc((100% - 4px - (var(--count) - 1) * var(--segment-gap)) / var(--count));
  border-radius: 4px;
  background: var(--mdg-select);
  transform: translateX(calc(var(--index, 0) * (100% + var(--segment-gap))));
  transition: transform var(--mdg-motion-fast) var(--mdg-ease);
  pointer-events: none;
}

.pen-menu .row-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--mdg-muted);
}

.pen-menu .row-label .value {
  flex: 1;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A colour token is code. */
.pen-menu .pen-colours .row-label .value {
  font-family: var(--vscode-editor-font-family, monospace);
}

.pen-menu .pen-colours {
  position: relative;
}

.pen-menu .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.pen-menu button.chip {
  width: 20px;
  height: 20px;
  min-width: 20px;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--mdg-fg) 22%, transparent);
  border-radius: 50%;
  background: var(--chip, transparent);
  cursor: pointer;
  transition: transform var(--mdg-motion-fast) var(--mdg-ease);
}

.pen-menu button.chip:hover {
  transform: scale(1.12);
}

.pen-menu button.chip:focus-visible {
  outline: 2px solid var(--mdg-focus);
  outline-offset: 3px;
}

/* The ring around the colour chosen, which slides from the one chosen before. */
.pen-menu .pen-ring {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  border-radius: 50%;
  box-shadow:
    0 0 0 2px var(--vscode-menu-background, #fff),
    0 0 0 4px var(--mdg-select);
  pointer-events: none;
  transition: transform var(--mdg-motion-fast) var(--mdg-ease);
}

.pen-menu.still :is(.pen-slider, .pen-ring) {
  transition: none;
}

.pen-menu input[type="color"] {
  flex: none;
  width: 26px;
  height: 20px;
  padding: 1px;
  border: 1px solid var(--mdg-border);
  border-radius: 4px;
  background: none;
  cursor: pointer;
}

.pen-menu input[type="color"]:focus-visible {
  outline: 2px solid var(--mdg-focus);
  outline-offset: 1px;
}

.menu [role="menuitem"][aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}

.menu .key {
  opacity: 0.7;
}

.menu [role="separator"] {
  height: 1px;
  margin: 4px 0;
  background: var(--vscode-menu-separatorBackground, var(--mdg-border));
}

.picker input {
  width: calc(100% - 12px);
  margin: 2px 6px 4px;
  padding: 3px 6px;
  border: 1px solid var(--vscode-input-border, var(--mdg-border));
  background: var(--vscode-input-background, #fff);
  color: var(--vscode-input-foreground, inherit);
  font: inherit;
}

.picker [role="option"] {
  padding: 3px 12px;
  cursor: pointer;
}

.picker [role="option"][aria-selected="true"] {
  background: var(--vscode-list-activeSelectionBackground, #0060c0);
  color: var(--vscode-list-activeSelectionForeground, #fff);
}

:is(.dialog, .icon-dialog) {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.25);
}

:is(.dialog, .icon-dialog) .box {
  max-width: 420px;
  padding: 14px 16px;
  border: 1px solid var(--mdg-border);
  border-radius: 6px;
  background: var(--vscode-editorWidget-background, #fff);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.dialog ul {
  margin: 8px 0 12px;
  padding-left: 18px;
  max-height: 200px;
  overflow: auto;
}

:is(.dialog, .icon-dialog) .buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

:is(.dialog, .icon-dialog) button {
  padding: 4px 12px;
  border: 1px solid var(--vscode-button-border, transparent);
  border-radius: 3px;
  background: var(--vscode-button-secondaryBackground, #ddd);
  color: var(--vscode-button-secondaryForeground, inherit);
  font: inherit;
  cursor: pointer;
}

:is(.dialog, .icon-dialog) .title {
  margin-bottom: 10px;
  font-weight: 600;
}

:is(.dialog, .icon-dialog) .box > label {
  display: block;
  margin-bottom: 2px;
  font-size: 12px;
  color: var(--mdg-muted);
}

:is(.dialog, .icon-dialog) input[type="text"] {
  width: 100%;
  padding: 3px 6px;
  border: 1px solid var(--vscode-input-border, var(--mdg-border));
  border-radius: 3px;
  background: var(--vscode-input-background, #fff);
  color: var(--vscode-input-foreground, inherit);
  font: inherit;
}

:is(.dialog, .icon-dialog) input:focus-visible {
  outline: 2px solid var(--mdg-focus);
  outline-offset: -1px;
}

:is(.dialog, .icon-dialog) .hint {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--mdg-muted);
}

:is(.dialog, .icon-dialog) .hint.error {
  color: var(--vscode-errorForeground, #c42b1c);
}

.dialog fieldset {
  margin: 10px 0 12px;
  padding: 6px 8px;
  border: 1px solid var(--mdg-border);
  border-radius: 4px;
}

.dialog .choice {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 4px 0;
}

.dialog .choice:has(input[disabled]) {
  opacity: 0.6;
}

:is(.dialog, .icon-dialog) button.primary {
  background: var(--vscode-button-background, #0e639c);
  color: var(--vscode-button-foreground, #fff);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Story mode ------------------------------------------------------------- */

#app.story-mode {
  grid-template-rows: auto 1fr auto;
}

.toolbar.story-mode [data-edit],
.main.story-mode .panel,
.stage.story-mode .overlay,
.stage.story-mode .presence,
.stage.story-mode .minimap,
.stage.story-mode .list-adds {
  display: none !important;
}

/*
 * View-only mode: a canvas whose host sent `readOnly` hides what writes the document, the way story
 * mode hides `data-edit`, but only what is marked `data-write`: the palette, Arrange, the snap, the
 * libraries and the story's editing controls. Zoom, fit, the minimap, effects and export stay.
 */
.view-only [data-write] {
  display: none !important;
}

.toolbar .view-only-badge {
  margin-left: auto;
  padding: 1px 8px;
  border: 1px solid var(--mdg-border);
  border-radius: 9px;
  color: var(--mdg-muted);
  font-size: 11px;
  cursor: default;
}

/* Two badges: the layout's one keeps its distance from the first, which goes to the right. */
.toolbar .view-only-badge:not([hidden]) + .badge {
  margin-left: 4px;
}

/* The values of a disabled field are what a viewer reads: keep them legible. */
.panel[data-readonly] input:disabled,
.panel[data-readonly] select:disabled,
.panel[data-readonly] textarea:disabled {
  color: inherit;
  opacity: 0.85;
}

.content .story-selected {
  filter: drop-shadow(0 0 2px var(--mdg-select)) drop-shadow(0 0 1px var(--mdg-select));
}

.timeline {
  --label-width: 140px;
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  max-height: 40vh;
  border-top: 1px solid var(--mdg-border);
  background: var(--mdg-panel);
  outline: none;
}

.timeline[hidden] {
  display: none;
}

/* Story mode comes in with its timeline rising from the foot of the canvas. */
.timeline:not([hidden]) {
  animation: mdg-rise-in var(--mdg-motion-slow) var(--mdg-ease);
}

.timeline:focus-visible {
  box-shadow: inset 0 0 0 1px var(--mdg-focus);
}

.timeline-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
}

/* The bar's words never wrap: on a narrow canvas the buttons keep their glyphs and names alone. */
.timeline-bar button {
  flex: none;
  white-space: nowrap;
}

.timeline-bar .scene-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@container (max-width: 760px) {
  .timeline-bar button .label {
    display: none;
  }
}

.timeline-bar .spacer {
  flex: 1;
}

.timeline-bar button,
.timeline-bar select {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  min-width: 24px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.timeline-bar select {
  border-color: var(--vscode-dropdown-border, var(--mdg-border));
  background: var(--vscode-dropdown-background, transparent);
  color: var(--vscode-dropdown-foreground, inherit);
}

.timeline-bar button:hover:not(:disabled) {
  background: var(--vscode-toolbar-hoverBackground, rgba(128, 128, 128, 0.15));
}

.timeline-bar button:disabled {
  opacity: 0.4;
  cursor: default;
}

.timeline-bar button[aria-pressed="true"] {
  background: var(--vscode-toolbar-activeBackground, rgba(128, 128, 128, 0.25));
}

.timeline-bar svg {
  width: 16px;
  height: 16px;
}

.timeline-bar .clock {
  min-width: 96px;
  font-variant-numeric: tabular-nums;
}

.timeline-bar .scene-name {
  color: var(--mdg-muted);
}

.timeline .tracks {
  position: relative;
  overflow-y: auto;
  padding-bottom: 6px;
}

.timeline .ruler {
  position: relative;
  height: 18px;
  margin-left: var(--label-width);
  border-bottom: 1px solid var(--mdg-border);
  cursor: ew-resize;
  font-size: 10px;
  color: var(--mdg-muted);
}

.timeline .tick {
  position: absolute;
  top: 2px;
  padding-left: 3px;
  border-left: 1px solid var(--mdg-border);
  white-space: nowrap;
}

.timeline .scene-row {
  display: grid;
  grid-template-columns: var(--label-width) 1fr;
  border-bottom: 1px solid color-mix(in srgb, var(--mdg-border) 50%, transparent);
}

.timeline .scene-label {
  padding: 3px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.timeline .lanes {
  position: relative;
  min-height: 20px;
}

.timeline .scene-band {
  position: absolute;
  top: 0;
  bottom: 0;
  background: color-mix(in srgb, var(--mdg-select) 6%, transparent);
}

.timeline .bar {
  position: absolute;
  height: 16px;
  min-width: 4px;
  overflow: hidden;
  border-radius: 3px;
  background: color-mix(in srgb, var(--mdg-select) 35%, var(--vscode-editor-background, #fff));
  border: 1px solid var(--mdg-select);
  font-size: 11px;
  line-height: 14px;
  cursor: pointer;
}

.timeline .bar.bar-hold {
  background: transparent;
  border-style: dashed;
}

.timeline .bar.bar-transition {
  background: color-mix(in srgb, var(--mdg-guide) 25%, var(--vscode-editor-background, #fff));
  border-color: var(--mdg-guide);
}

.timeline .bar.selected {
  box-shadow: 0 0 0 2px var(--mdg-focus);
}

.timeline .bar-text {
  padding: 0 4px;
  white-space: nowrap;
  pointer-events: none;
}

.timeline .grip {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 6px;
  cursor: ew-resize;
  background: color-mix(in srgb, var(--mdg-select) 60%, transparent);
}

.timeline .playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--vscode-editorCursor-foreground, #e0398c);
  pointer-events: none;
}

.toolbar.story-mode .separator {
  display: none;
}

/* Text group of the strip --------------------------------------------- */

/* The font, size and weight of the selection's text, under a small heading (decision 0067). */
.panel .text-group {
  display: grid;
  gap: 6px;
  margin: 2px 0 8px;
  padding-top: 6px;
  border-top: 1px dashed color-mix(in srgb, var(--mdg-border) 80%, transparent);
}

.panel .text-group .group-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--mdg-muted);
}

.panel .text-group .field {
  margin-bottom: 0;
}

/* The Font button: the family's name drawn in the family, with a chevron. */
.panel .font-button {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  height: 28px;
  padding: 0 6px 0 8px;
  border: 1px solid var(--vscode-input-border, var(--mdg-border));
  border-radius: 5px;
  background: var(--vscode-input-background, #fff);
  color: var(--vscode-input-foreground, var(--mdg-fg));
  cursor: pointer;
  text-align: left;
  transition:
    border-color var(--mdg-motion-fast) var(--mdg-ease),
    box-shadow var(--mdg-motion-fast) var(--mdg-ease),
    background-color var(--mdg-motion-fast) var(--mdg-ease);
}

.panel .font-button:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--mdg-select) 55%, var(--mdg-border));
}

.panel .font-button:focus-visible,
.panel .font-button[aria-expanded="true"] {
  outline: none;
  border-color: var(--mdg-focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mdg-focus) 22%, transparent);
}

.panel .font-button:disabled {
  cursor: default;
  opacity: 0.6;
}

.panel .font-button .font-button-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* What applies without a written family, a stack written by hand, a mixed selection: greyed. */
.panel .font-button:is(.inherited, .custom, .mixed) .font-button-name {
  color: var(--mdg-muted);
}

.panel .font-button.custom .font-button-name,
.panel .font-button.mixed .font-button-name {
  font-style: italic;
}

.panel .font-button svg {
  flex: none;
  width: 14px;
  height: 14px;
  color: var(--mdg-muted);
  transition: transform var(--mdg-motion-fast) var(--mdg-ease);
}

.panel .font-button[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

/* The size: − and + around the field, and Theme. */
.panel .size-row {
  gap: 4px;
}

.panel .size-row .size-input {
  flex: 1;
  min-width: 44px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.panel .size-row .size-input[aria-invalid] {
  border-color: var(--vscode-inputValidation-errorBorder, #d33);
}

.panel .size-row button.step {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--vscode-button-border, var(--mdg-border));
  border-radius: 4px;
  background: var(--vscode-button-secondaryBackground, transparent);
  color: var(--vscode-button-secondaryForeground, inherit);
  cursor: pointer;
  transition:
    background-color var(--mdg-motion-fast) var(--mdg-ease),
    transform var(--mdg-motion-fast) var(--mdg-ease);
}

.panel .size-row button.step:hover:not(:disabled) {
  background: color-mix(in srgb, var(--mdg-select) 12%, transparent);
}

.panel .size-row button.step:active:not(:disabled) {
  transform: scale(0.92);
}

.panel .size-row button.step:focus-visible {
  outline: 2px solid var(--mdg-focus);
  outline-offset: 1px;
}

.panel .size-row button.step svg {
  width: 14px;
  height: 14px;
}

.panel .field-note {
  font-size: 11px;
  color: var(--vscode-errorForeground, #d33);
  animation: mdg-fade-in var(--mdg-motion-fast) var(--mdg-ease);
}

.panel .field-note[hidden] {
  display: none;
}

/* Font picker ------------------------------------------------------------ */

.font-picker {
  position: absolute;
  z-index: 12;
  display: flex;
  flex-direction: column;
  width: 280px;
  max-width: calc(100% - 16px);
  max-height: 440px;
  padding-top: 8px;
  overflow: hidden;
  border: 1px solid var(--vscode-menu-border, var(--mdg-border));
  border-radius: 8px;
  background: var(--vscode-menu-background, #fff);
  color: var(--vscode-menu-foreground, inherit);
  box-shadow: var(--mdg-pop-shadow);
}

.font-results {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 6px 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.font-group-title {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 6px 6px 3px;
  background: var(--vscode-menu-background, #fff);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--mdg-muted);
}

/* A row: the family's name and "Aa" in the family, one height whether its faces have arrived. */
.font-option {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  transition:
    background-color var(--mdg-motion-fast) var(--mdg-ease),
    border-color var(--mdg-motion-fast) var(--mdg-ease),
    opacity var(--mdg-motion) var(--mdg-ease);
}

.font-option .font-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.font-option .font-sample {
  flex: none;
  font-size: 16px;
  color: var(--mdg-muted);
}

.font-option svg {
  flex: none;
  width: 14px;
  height: 14px;
  color: var(--mdg-muted);
}

/* A family whose faces are on their way: drawn in the interface font, a little faded. */
.font-option.waiting .font-name,
.font-option.waiting .font-sample {
  opacity: 0.7;
}

.font-option.inherit {
  margin-bottom: 2px;
  color: var(--mdg-muted);
  font-style: italic;
}

.font-option:hover,
.font-option.active {
  background: color-mix(in srgb, var(--mdg-select) 10%, transparent);
}

.font-option.active {
  border-color: color-mix(in srgb, var(--mdg-focus) 45%, transparent);
}

.font-option[aria-selected="true"] {
  border-color: color-mix(in srgb, var(--mdg-select) 55%, transparent);
  background: color-mix(in srgb, var(--mdg-select) 15%, transparent);
}

.font-option:active {
  transform: scale(0.98);
}

.font-picker-status {
  padding: 8px 12px 10px;
  font-size: 12px;
  color: var(--mdg-muted);
}

.font-picker-status[hidden] {
  display: none;
}

/* Icon picker ------------------------------------------------------------ */

.icon-picker {
  position: absolute;
  z-index: 12;
  display: flex;
  flex-direction: column;
  width: 372px;
  max-width: calc(100% - 16px);
  max-height: 520px;
  padding-top: 8px;
  overflow: hidden;
  border: 1px solid var(--vscode-menu-border, var(--mdg-border));
  border-radius: 8px;
  background: var(--vscode-menu-background, #fff);
  color: var(--vscode-menu-foreground, inherit);
  box-shadow: var(--mdg-pop-shadow);
}

/* A result dragged out: the picker fades away from the canvas under it and takes no presses. */
.icon-picker.lent {
  opacity: 0;
  transform: scale(var(--mdg-pop-scale));
  pointer-events: none;
}

.icon-picker-head {
  padding: 0 12px 6px;
  overflow: hidden;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--mdg-muted);
}

.icon-picker-head[hidden],
.icon-picker-status[hidden],
.icon-picker .placement[hidden] {
  display: none;
}

.icon-search {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  margin: 0 8px 8px;
  padding: 0 8px;
  border: 1px solid var(--vscode-input-border, var(--mdg-border));
  border-radius: 6px;
  background: var(--vscode-input-background, #fff);
  color: var(--mdg-muted);
  transition:
    border-color var(--mdg-motion-fast) var(--mdg-ease),
    box-shadow var(--mdg-motion-fast) var(--mdg-ease);
}

.icon-search:focus-within {
  border-color: var(--mdg-focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mdg-focus) 22%, transparent);
}

.icon-search svg {
  flex: none;
  width: 15px;
  height: 15px;
}

.icon-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--vscode-input-foreground, var(--mdg-fg));
  font: inherit;
}

.icon-search input::placeholder {
  color: var(--mdg-muted);
  opacity: 0.85;
}

/* The search field's clear button, drawn in the field's own colours. */
.icon-search input::-webkit-search-cancel-button {
  width: 14px;
  height: 14px;
  margin: 0;
  background: var(--mdg-muted);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 4l8 8M12 4l-8 8' stroke='black' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E")
    center / 14px 14px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 4l8 8M12 4l-8 8' stroke='black' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E")
    center / 14px 14px no-repeat;
}

.icon-search input::-webkit-search-cancel-button:hover {
  background: var(--mdg-fg);
}

.icon-picker .placement {
  margin: 0 8px 8px;
}

.icon-results {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 8px 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.icon-results[aria-busy="true"] .icon-grid {
  opacity: 0.6;
  transition: opacity var(--mdg-motion) var(--mdg-ease);
}

.icon-group + .icon-group {
  margin-top: 4px;
}

.icon-group-title {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 4px 4px;
  background: var(--vscode-menu-background, #fff);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--mdg-muted);
}

.icon-group-title .count {
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
}

.icon-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 0;
  padding: 7px 3px 5px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: grab;
  transition:
    background-color var(--mdg-motion-fast) var(--mdg-ease),
    border-color var(--mdg-motion-fast) var(--mdg-ease),
    transform var(--mdg-motion-fast) var(--mdg-ease);
}

.icon-option:hover {
  background: color-mix(in srgb, var(--mdg-select) 8%, transparent);
}

.icon-option:active {
  transform: scale(0.96);
}

.icon-option[aria-selected="true"] {
  border-color: color-mix(in srgb, var(--mdg-select) 55%, transparent);
  background: color-mix(in srgb, var(--mdg-select) 13%, transparent);
}

.icon-option .thumb,
.icon-drag .thumb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
}

.icon-option .thumb svg,
.icon-drag .thumb svg {
  width: 24px;
  height: 24px;
}

/* A thumbnail whose pack is still on its way. */
.icon-option .thumb.loading,
.panel .icon-thumb.loading {
  border-radius: 5px;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--mdg-fg) 6%, transparent) 25%,
    color-mix(in srgb, var(--mdg-fg) 13%, transparent) 50%,
    color-mix(in srgb, var(--mdg-fg) 6%, transparent) 75%
  );
  background-size: 300% 100%;
  animation: mdg-shimmer 1.2s linear infinite;
}

/* Two lines at most, broken between words (and after hyphens); a word longer than the result is
   cut with an ellipsis, the whole name in the result's title. */
/* An icon that no pack has: a question mark in a dashed tile, for good (no shimmer). */
.icon-option .thumb.missing,
.panel .icon-thumb.missing {
  border: 1px dashed var(--vscode-inputValidation-warningBorder, #b89500);
  border-radius: 5px;
  background: color-mix(
    in srgb,
    var(--vscode-inputValidation-warningBackground, #fce4b0) 55%,
    transparent
  );
  color: var(--vscode-inputValidation-warningBorder, #b89500);
}

.panel .icon-thumb.missing {
  border-radius: 7px;
}

.icon-option .thumb.missing svg,
.panel .icon-thumb.missing svg {
  width: 18px;
  height: 18px;
}

.icon-option .name {
  display: -webkit-box;
  max-width: 100%;
  overflow: hidden;
  font-size: 11px;
  line-height: 1.25;
  text-align: center;
  overflow-wrap: normal;
  word-break: normal;
  text-overflow: ellipsis;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* New results fade in, one after the other. */
.icon-option.fresh {
  animation: mdg-rise-in var(--mdg-motion) var(--mdg-ease) backwards;
  animation-delay: calc(var(--i, 0) * var(--mdg-stagger));
}

.icon-picker-status {
  padding: 18px 12px 20px;
  font-size: 12px;
  text-align: center;
  color: var(--mdg-muted);
}

.icon-picker-foot {
  padding: 6px 12px 7px;
  border-top: 1px solid var(--vscode-menu-separatorBackground, var(--mdg-border));
  background: color-mix(in srgb, var(--mdg-fg) 3%, transparent);
  font-size: 11px;
  color: var(--mdg-muted);
}

/* The foot holds the picker's hint and, on a canvas of a project, Add icon… at its end. */
.icon-picker-foot {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-picker-foot .hint {
  flex: 1;
  min-width: 0;
}

.icon-picker-foot button.add-icon,
.library-foot button.add-icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--vscode-button-border, var(--mdg-border));
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 11px;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--mdg-motion-fast) var(--mdg-ease),
    border-color var(--mdg-motion-fast) var(--mdg-ease);
}

.icon-picker-foot button.add-icon:hover,
.library-foot button.add-icon:hover {
  border-color: var(--mdg-focus);
  background: color-mix(in srgb, var(--mdg-focus) 10%, transparent);
}

.icon-picker-foot button.add-icon:focus-visible,
.library-foot button.add-icon:focus-visible {
  outline: 2px solid var(--mdg-focus);
  outline-offset: 1px;
}

.icon-picker-foot button.add-icon svg,
.library-foot button.add-icon svg {
  width: 12px;
  height: 12px;
}

.library-foot {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--mdg-border);
}

.library-foot:has(> button[hidden]) {
  display: none;
}

/* The Add icon dialog: the pack, the licence of a new one, and a row per file. */
.add-icons .box {
  display: flex;
  flex-direction: column;
  width: min(460px, calc(100% - 32px));
  max-width: none;
  max-height: calc(100% - 32px);
}

.add-icons .rows-title,
.add-icons .licence > label {
  display: block;
  margin: 10px 0 4px;
  font-size: 12px;
  color: var(--mdg-muted);
}

.add-icons .licence .row {
  display: flex;
  gap: 6px;
}

.add-icons select,
.add-icons .licence-other {
  flex: 1;
  min-width: 0;
  height: 26px;
  padding: 2px 6px;
  border: 1px solid var(--vscode-input-border, var(--mdg-border));
  border-radius: 3px;
  background: var(--vscode-input-background, #fff);
  color: var(--vscode-input-foreground, inherit);
  font: inherit;
}

.add-icons .icon-rows {
  display: grid;
  gap: 6px;
  min-height: 0;
  max-height: 300px;
  margin: 0 0 8px;
  padding: 0 2px 0 0;
  overflow: auto;
  list-style: none;
  scrollbar-width: thin;
}

.add-icons .icon-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 6px;
  border: 1px solid var(--mdg-border);
  border-radius: 6px;
  animation: mdg-rise-in var(--mdg-motion) var(--mdg-ease) both;
  animation-delay: calc(var(--i, 0) * 24ms);
  transition:
    opacity var(--mdg-motion-fast) var(--mdg-ease),
    border-color var(--mdg-motion-fast) var(--mdg-ease),
    display var(--mdg-motion-fast) allow-discrete;
}

.add-icons .icon-row:has(input[aria-invalid="true"]) {
  border-color: var(--vscode-inputValidation-errorBorder, #be1100);
}

.add-icons .icon-row.left-out {
  opacity: 0.62;
}

.add-icons .icon-row.gone {
  display: none;
  opacity: 0;
}

.add-icons .thumb {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--mdg-fg) 4%, transparent);
  color: var(--mdg-fg);
}

.add-icons .thumb svg {
  width: 40px;
  height: 40px;
  animation: mdg-fade-in var(--mdg-motion) var(--mdg-ease);
}

.add-icons .thumb.loading {
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--mdg-fg) 6%, transparent) 25%,
    color-mix(in srgb, var(--mdg-fg) 13%, transparent) 50%,
    color-mix(in srgb, var(--mdg-fg) 6%, transparent) 75%
  );
  background-size: 300% 100%;
  animation: mdg-shimmer 1.2s linear infinite;
}

.add-icons .thumb.refused {
  color: var(--vscode-errorForeground, #c42b1c);
}

.add-icons .thumb.refused svg {
  width: 20px;
  height: 20px;
}

.add-icons .fields {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.add-icons .file {
  overflow: hidden;
  font-size: 11px;
  color: var(--mdg-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.add-icons input[aria-invalid="true"] {
  border-color: var(--vscode-inputValidation-errorBorder, #be1100);
}

.add-icons .problem {
  min-height: 15px;
  font-size: 11px;
  color: var(--mdg-muted);
  transition: color var(--mdg-motion-fast) var(--mdg-ease);
}

.add-icons .problem.error,
.add-icons .add-status.error {
  color: var(--vscode-errorForeground, #c42b1c);
}

.add-icons button.remove {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--mdg-muted);
}

.add-icons button.remove:hover {
  border-color: var(--mdg-border);
  color: inherit;
}

.add-icons button.remove svg {
  width: 12px;
  height: 12px;
}

.add-icons .add-status {
  min-height: 16px;
  margin-bottom: 6px;
}

.add-icons button.primary[disabled] {
  opacity: 0.5;
  cursor: default;
}

/* The icon under the pointer while it is dragged onto the canvas. */
.icon-drag {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  max-width: 120px;
  padding: 6px 8px 5px;
  border: 1px solid var(--mdg-border);
  border-radius: 8px;
  background: var(--vscode-menu-background, #fff);
  color: var(--vscode-menu-foreground, var(--mdg-fg));
  box-shadow: var(--mdg-pop-shadow);
  pointer-events: none;
  will-change: transform;
  transition:
    border-color var(--mdg-motion-fast) var(--mdg-ease),
    opacity var(--mdg-motion-fast) var(--mdg-ease);
  animation: mdg-fade-in var(--mdg-motion-fast) var(--mdg-ease);
}

.icon-drag .name {
  max-width: 100%;
  overflow: hidden;
  font-size: 11px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Over a shape that takes the icon. */
.icon-drag.onto {
  border-color: var(--mdg-select);
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--mdg-select) 30%, transparent),
    var(--mdg-pop-shadow);
}

/* Off the canvas, where a release does nothing. */
.icon-drag.outside {
  opacity: 0.6;
}

/* The placement control: the icon picker's and the Libraries panel's. */
.placement {
  display: flex;
  align-items: center;
  gap: 8px;
}

.placement-label {
  font-size: 11px;
  white-space: nowrap;
  color: var(--mdg-muted);
}

.placement-choices {
  display: flex;
  flex: 1;
  gap: 2px;
  padding: 2px;
  border-radius: 7px;
  background: color-mix(in srgb, var(--mdg-fg) 7%, transparent);
}

:is(.panel, .icon-picker) button.placement-choice {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 0;
  height: auto;
  padding: 4px 4px 3px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--mdg-muted);
  font: inherit;
  font-size: 11px;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--mdg-motion-fast) var(--mdg-ease),
    color var(--mdg-motion-fast) var(--mdg-ease),
    box-shadow var(--mdg-motion-fast) var(--mdg-ease);
}

:is(.panel, .icon-picker) button.placement-choice:hover {
  color: var(--mdg-fg);
  background: color-mix(in srgb, var(--mdg-fg) 6%, transparent);
}

:is(.panel, .icon-picker) button.placement-choice[aria-checked="true"] {
  background: var(--vscode-input-background, #fff);
  color: var(--mdg-fg);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.14),
    0 0 0 1px color-mix(in srgb, var(--mdg-select) 45%, transparent);
}

:is(.panel, .icon-picker) button.placement-choice:focus-visible {
  outline: 2px solid var(--mdg-focus);
  outline-offset: 1px;
}

.placement-choice svg {
  flex: none;
  width: 32px;
  height: 20px;
}

.placement-choice .name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* In the narrow Libraries panel the words go above the choices. */
.panel .placement {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  margin: 0 0 10px;
}

/* The inspector's Icon field: the icon's picture and name, Choose… and Remove beside its label. */
.panel .field-head {
  display: flex;
  align-items: center;
  gap: 4px;
}

.panel .field-head > label,
.panel .field-head > .field-label {
  flex: 1;
  min-width: 0;
}

.panel .field-label {
  font-size: 12px;
  color: var(--mdg-muted);
}

.panel .quicks {
  display: inline-flex;
  gap: 4px;
}

.panel button.quick.small,
.panel button.choose.small {
  height: 20px;
  padding: 0 7px;
  font-size: 11px;
}

.panel button.quick[aria-pressed="true"] {
  border-color: var(--mdg-select);
  background: color-mix(in srgb, var(--mdg-select) 16%, transparent);
  color: var(--mdg-fg);
}

.panel .icon-value {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.panel .icon-thumb {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--vscode-input-border, var(--mdg-border));
  border-radius: 7px;
  background: var(--vscode-input-background, #fff);
  color: var(--mdg-fg);
}

.panel .icon-thumb svg {
  width: 24px;
  height: 24px;
}

/* An icon from a class or a rule, not written on the element: greyed. */
.panel .icon-thumb.inherited svg {
  opacity: 0.5;
}

.panel .icon-thumb.none {
  border-style: dashed;
  background: transparent;
}

.panel .icon-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.panel .icon-name,
.panel .icon-reference {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.panel .icon-reference {
  font-family: var(--vscode-editor-font-family, monospace);
  font-size: 11px;
  color: var(--mdg-muted);
}

.panel .icon-field .icon-row {
  margin-top: 2px;
}

/* Five pictures of where an icon goes, four of where its label goes: narrower chips in a row. */
.panel button.chip.glyph.narrow {
  width: 30px;
  min-width: 30px;
}

/* Their default: the picture of what applies, greyed in a dashed chip, as wide as the others. */
.panel button.chip.glyph.inherit.pictured {
  width: 30px;
  padding: 0;
  border-style: dashed;
  background: transparent;
}

.panel button.chip.glyph.inherit.pictured svg {
  opacity: 0.55;
  transition: opacity var(--mdg-motion-fast) var(--mdg-ease);
}

/* On a mixed selection, an arrow back to each one's own default. */
.panel button.chip.glyph.inherit.pictured svg:not([data-glyph]) {
  width: 14px;
  height: 14px;
}

.panel button.chip.glyph.inherit.pictured:hover svg,
.panel button.chip.glyph.inherit.pictured[aria-checked="true"] svg {
  opacity: 0.8;
}

/* A picture row's value goes under its name when both do not fit one line (in Spanish). */
.panel .glyph-row .row-label,
.panel .align-field .row-label {
  flex-wrap: wrap;
  row-gap: 0;
}

.panel .glyph-row .row-label .value,
.panel .align-field .row-label .value {
  flex: 1 0 auto;
  max-width: 100%;
}

/* Tooltips ----------------------------------------------------------------- */

.tooltip {
  position: fixed;
  z-index: 50;
  max-width: 300px;
  padding: 4px 8px 5px;
  border: 1px solid var(--mdg-tip-border);
  border-radius: 5px;
  background: var(--mdg-tip-bg);
  color: var(--mdg-tip-fg);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.22);
  font-size: 12px;
  line-height: 1.35;
  pointer-events: none;
  transition:
    opacity var(--mdg-motion-fast) var(--mdg-ease),
    transform var(--mdg-motion-fast) var(--mdg-ease),
    display var(--mdg-motion-fast) allow-discrete;
}

.tooltip[hidden] {
  display: none;
  opacity: 0;
  transition:
    opacity var(--mdg-motion-fast) var(--mdg-ease-in),
    display var(--mdg-motion-fast) allow-discrete;
}

@starting-style {
  .tooltip:not([hidden]) {
    opacity: 0;
    transform: translateY(calc(-1 * var(--mdg-rise) / 2));
  }

  .tooltip[data-side="top"]:not([hidden]) {
    transform: translateY(calc(var(--mdg-rise) / 2));
  }
}

/* Motion ----------------------------------------------------------------- */

/*
 * Popovers and menus: the icon picker, the shapes grid, the menus (context, arrow kinds, New
 * diagram, kinds of group, Arrange), Connect to…, and the inspector's picture grids. They rise from
 * their anchor and fade in as they open, fade as they close, and take no presses while closing.
 */
:is(.menu, .picker, .shape-menu, .pen-menu, .icon-picker, .font-picker, .panel .head-grid) {
  transform-origin: top left;
  transition:
    opacity var(--mdg-motion) var(--mdg-ease),
    transform var(--mdg-motion) var(--mdg-ease),
    display var(--mdg-motion) allow-discrete;
}

:is(
  .menu,
  .picker,
  .shape-menu,
  .pen-menu,
  .icon-picker,
  .font-picker,
  .panel .head-grid
)[data-side="top"] {
  transform-origin: bottom left;
}

:is(.menu, .picker, .shape-menu, .pen-menu, .icon-picker, .font-picker, .panel .head-grid)[hidden] {
  display: none;
  opacity: 0;
  transform: scale(var(--mdg-pop-scale));
  pointer-events: none;
  transition:
    opacity var(--mdg-motion-fast) var(--mdg-ease-in),
    transform var(--mdg-motion-fast) var(--mdg-ease-in),
    display var(--mdg-motion-fast) allow-discrete;
}

@starting-style {
  :is(.menu, .picker, .shape-menu, .pen-menu, .icon-picker, .font-picker, .panel .head-grid):not(
    [hidden]
  ) {
    opacity: 0;
    transform: translateY(calc(-1 * var(--mdg-rise))) scale(var(--mdg-pop-scale));
  }

  :is(
      .menu,
      .picker,
      .shape-menu,
      .pen-menu,
      .icon-picker,
      .font-picker,
      .panel .head-grid
    )[data-side="top"]:not([hidden]) {
    transform: translateY(var(--mdg-rise)) scale(var(--mdg-pop-scale));
  }
}

/* A dialog's backdrop and box fade in. */
:is(.dialog, .icon-dialog):not([hidden]) {
  animation: mdg-fade-in var(--mdg-motion) var(--mdg-ease);
}

:is(.dialog, .icon-dialog):not([hidden]) .box {
  animation: mdg-rise-in var(--mdg-motion) var(--mdg-ease);
}

/* Side panels slide in beside the stage: Libraries and Layers from the left, the properties and
   the theme from the right. */
.side .panel:not([hidden]) {
  animation: mdg-slide-right var(--mdg-motion-slow) var(--mdg-ease);
}

.main > .panel:not([hidden]) {
  animation: mdg-slide-left var(--mdg-motion-slow) var(--mdg-ease);
}

/* Target outlines (a connection's, a drop's) and the editor in place fade in as they appear. */
.overlay .highlight:not(.held) {
  animation: mdg-fade-in var(--mdg-motion) var(--mdg-ease);
}

.inline {
  animation: mdg-outline-in var(--mdg-motion) var(--mdg-ease);
}

/* A new sticky note pops in as its editor opens over it: it grows from --mdg-pop-scale about the
   card's centre (set on the group) and fades in. */
.content svg g.mdg-pop {
  transform-box: view-box;
  animation: mdg-pop-in var(--mdg-motion) var(--mdg-ease);
}

/* A tag removed from its pill's menu or its emptied editor fades out while the edit is drawn. */
.content svg g.mdg-fading {
  animation: mdg-fade-out var(--mdg-motion-fast) var(--mdg-ease-in) forwards;
}

/* Buttons, chips, items and fields change colour smoothly. */
.toolbar button,
.toolbar select,
.panel button,
.panel input,
.panel select,
.panel textarea,
.menu [role="menuitem"],
.menu [role="menuitemradio"],
.picker [role="option"],
.shape-menu button.chip,
.library-item,
.library-section .category,
.empty .empty-actions button,
:is(.dialog, .icon-dialog) button {
  transition:
    background-color var(--mdg-motion-fast) var(--mdg-ease),
    border-color var(--mdg-motion-fast) var(--mdg-ease),
    color var(--mdg-motion-fast) var(--mdg-ease),
    box-shadow var(--mdg-motion-fast) var(--mdg-ease),
    outline-color var(--mdg-motion-fast) var(--mdg-ease),
    opacity var(--mdg-motion-fast) var(--mdg-ease);
}

/*
 * The alignment picker: nine cells (a text's row of three) of a text block's place in a box, the
 * pressed cell over a highlight that slides from the one pressed before, the default greyed in a
 * dashed cell, and the chip that takes both alignments away beside the grid.
 */
.inspector .align-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.panel .align-row button.chip.align-inherit {
  height: 24px;
  margin-top: 2px;
}

.inspector .align-grid {
  --cell-width: 30px;
  --cell-height: 24px;
  --cell-gap: 2px;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--columns, 3), var(--cell-width));
  gap: var(--cell-gap);
  padding: 2px;
  border: 1px solid var(--mdg-border);
  border-radius: 6px;
}

.inspector .align-cell {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: var(--cell-width);
  height: var(--cell-height);
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  color: var(--mdg-muted);
  cursor: pointer;
  transition:
    color var(--mdg-motion-fast) var(--mdg-ease),
    background-color var(--mdg-motion-fast) var(--mdg-ease),
    transform var(--mdg-motion-fast) var(--mdg-ease);
}

.inspector .align-cell:hover:not(:disabled) {
  background: color-mix(in srgb, var(--mdg-select) 10%, transparent);
  color: inherit;
}

.inspector .align-cell:active:not(:disabled) {
  transform: scale(0.98);
}

.inspector .align-cell[aria-checked="true"] {
  color: var(--vscode-button-foreground, #fff);
}

.inspector .align-cell.inherit {
  border-style: dashed;
  border-color: color-mix(in srgb, currentColor 45%, transparent);
  opacity: 0.75;
}

.inspector .align-cell:focus-visible {
  outline: 2px solid var(--mdg-select);
  outline-offset: 1px;
}

.inspector .align-cell:disabled {
  cursor: default;
}

.inspector .align-highlight {
  position: absolute;
  top: 2px;
  left: 2px;
  width: var(--cell-width);
  height: var(--cell-height);
  border-radius: 4px;
  background: var(--mdg-select);
  transform: translate(
    calc(var(--column, 0) * (var(--cell-width) + var(--cell-gap))),
    calc(var(--row, 0) * (var(--cell-height) + var(--cell-gap)))
  );
  transition: transform var(--mdg-motion-fast) var(--mdg-ease);
  pointer-events: none;
}

@keyframes mdg-fade-in {
  from {
    opacity: 0;
  }
}

@keyframes mdg-fade-out {
  to {
    opacity: 0;
  }
}

@keyframes mdg-rise-in {
  from {
    opacity: 0;
    transform: translateY(var(--mdg-rise)) scale(var(--mdg-pop-scale));
  }
}

@keyframes mdg-slide-right {
  from {
    opacity: 0;
    transform: translateX(calc(-1 * var(--mdg-slide)));
  }
}

@keyframes mdg-slide-left {
  from {
    opacity: 0;
    transform: translateX(var(--mdg-slide));
  }
}

@keyframes mdg-pop-in {
  from {
    opacity: 0;
    transform: scale(var(--mdg-pop-scale));
  }
}

@keyframes mdg-outline-in {
  from {
    outline-color: transparent;
    outline-offset: 5px;
  }
}

@keyframes mdg-shimmer {
  to {
    background-position: -150% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .icon-option .thumb.loading,
  .panel .icon-thumb.loading,
  .add-icons .thumb.loading {
    animation: none;
  }
}
