dialog.shape-picker[open] {
  position: fixed;
  inset: auto;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  max-width: none;
  max-height: none;
  overflow: hidden;
  border: 1px solid #988068;
  border-radius: 8px;
  box-shadow:
    0 12px 38px #281a0c38,
    0 2px 6px #281a0c20;
  animation: shape-sheet-in 0.14s ease-out;
}
.shape-picker::backdrop {
  background: rgba(38, 30, 22, 0.24);
}
.shape-heading {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
  padding: 12px 16px 7px;
}
.shape-heading h2 {
  margin: 0;
  font: 600 21px/1.2 var(--serif);
}
.shape-heading button,
.shape-empty button {
  min-height: 32px;
  padding: 3px 10px;
  border: 1px solid var(--rule);
  background: var(--field);
}
.shape-filters {
  display: flex;
  flex: none;
  gap: 6px;
  padding: 0 16px 10px;
  border-bottom: 1px solid var(--rule);
}
.shape-filters input,
.shape-filters select {
  box-sizing: border-box;
  min-width: 0;
  min-height: 34px;
  padding: 4px 9px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--ink);
  background: var(--field);
  font: inherit;
}
.shape-filters input {
  flex: 1;
}
.shape-filters select {
  display: none;
}
.shape-browser {
  display: flex;
  flex: 1;
  min-height: 0;
}
.shape-categories,
.shape-results {
  overflow-y: auto;
  overscroll-behavior: contain;
}
.shape-categories {
  flex: 0 0 130px;
  box-sizing: border-box;
  padding: 11px 8px;
  border-right: 1px solid var(--rule);
}
.shape-categories button {
  display: block;
  width: 100%;
  min-height: 34px;
  margin-bottom: 3px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  text-align: left;
}
.shape-categories button[aria-pressed='true'] {
  color: var(--accent);
  border-color: #ad85625e;
  background: var(--selected);
}
.shape-categories button:hover {
  color: var(--accent);
}
.shape-results {
  flex: 1;
  min-width: 0;
  padding: 12px;
  scrollbar-gutter: stable;
  background: color-mix(in srgb, var(--sheet) 45%, transparent);
}
.shape-results section + section {
  margin-top: 14px;
}
.shape-results h3 {
  margin: 0 0 6px;
  color: var(--muted);
  font: 600 13px/1.25 var(--sans);
}
.shape-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(83px, 1fr));
  gap: 5px;
}
.shape-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  min-height: 75px;
  padding: 4px;
  border: 1px solid var(--hair);
  border-radius: 4px;
  background: var(--field);
  color: var(--ink);
  font: 12px/1.16 var(--sans);
  text-align: center;
  overflow-wrap: anywhere;
}
.shape-tile:hover,
.shape-tile[aria-pressed='true'] {
  color: var(--accent);
  border-color: var(--accent);
}
.shape-tile[aria-pressed='true'] {
  background: var(--selected);
}
.shape-thumbnail {
  width: 61px;
  height: 38px;
  max-width: 100%;
  fill: none;
  overflow: visible;
}
.shape-tile .shape-thumbnail {
  flex: none;
}
.shape-picker :is(button, input, select):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.shape-empty {
  padding: 12px;
  text-align: center;
}
.shape-empty p {
  margin: 0 0 8px;
  color: var(--muted);
}
.shape-hint {
  margin: 0;
  padding: 7px 16px;
  flex: none;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font: 12px/1.35 var(--sans);
}
.shape-picker .shape-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-right: 8px;
  border-top: 1px solid var(--rule);
}
.shape-picker .shape-footer .shape-hint {
  border: 0;
  padding-block: 6px;
}
.shape-surface-action {
  flex: none;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
@keyframes shape-sheet-in {
  from {
    opacity: 0.65;
    translate: 0 12px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}
@media (max-width: 640px) {
  dialog.shape-picker[open] {
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-bottom: none;
    border-radius: 12px 12px 0 0;
  }
  .shape-heading {
    padding: 16px 12px 6px;
    touch-action: none;
  }
  .shape-heading::before {
    content: '';
    position: absolute;
    top: 6px;
    left: calc(50% - 17px);
    width: 34px;
    height: 3px;
    border-radius: 3px;
    background: var(--rule);
  }
  .shape-filters {
    padding: 0 12px 8px;
  }
  .shape-filters select {
    display: block;
    flex: 0 1 auto;
    max-width: 43%;
  }
  .shape-categories {
    display: none;
  }
  .shape-results {
    padding: 10px;
    scrollbar-gutter: auto;
  }
  .shape-grid {
    grid-template-columns: repeat(auto-fill, minmax(73px, 1fr));
    gap: 4px;
  }
  .shape-tile {
    min-height: 70px;
  }
  .shape-hint {
    padding: 6px 12px;
  }
}
@media (max-height: 420px) {
  .shape-heading {
    padding-block: 4px;
  }
  .shape-heading::before {
    content: none;
  }
  .shape-filters {
    padding-bottom: 5px;
  }
}
@media (prefers-reduced-motion: reduce) {
  dialog.shape-picker[open] {
    animation: none;
  }
}
