: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);
}

.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;
}

/* 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;
}

.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"] {
  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 {
  fill: var(--mdg-select);
  cursor: grab;
  animation: mdg-fade-in var(--mdg-motion-fast) var(--mdg-ease);
  transition: r var(--mdg-motion-fast) var(--mdg-ease);
}

.overlay .handle.rotate:hover {
  r: 7.5;
}

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

/* An element turned by its rotation handle eases between the steps. */
.content g.turning {
  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;
}

.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;
}

.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);
}

/* 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;
}

/* 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;
}

.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,
.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;
  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;
}

.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;
  margin-bottom: 8px;
}

.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);
}

.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;
}

.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);
}

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

.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;
}

.dialog .buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.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;
}

.dialog .title {
  margin-bottom: 10px;
  font-weight: 600;
}

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

.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;
}

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

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

.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;
}

.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 {
  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;
  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;
}

.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;
}

.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;
}

/* 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 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 {
  flex-wrap: wrap;
  row-gap: 0;
}

.panel .glyph-row .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, .icon-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, .icon-picker, .panel .head-grid)[data-side="top"] {
  transform-origin: bottom left;
}

:is(.menu, .picker, .shape-menu, .icon-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, .icon-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, .icon-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. */
.dialog:not([hidden]) {
  animation: mdg-fade-in var(--mdg-motion) var(--mdg-ease);
}

.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);
}

/* 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,
.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);
}

@keyframes mdg-fade-in {
  from {
    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-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 {
    animation: none;
  }
}
