.sheet {
  position: fixed;
  inset: auto 0 0;
  width: 100%;
  max-width: 100%;
  flex-direction: column;
  max-height: var(--sheet-max-height);
  margin: 0;
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 0;
  box-shadow: var(--shadow-sheet);
  clip-path: inset(-100% -100% 100% -100%);
  transform: translateY(100%);
  transition:
    transform var(--duration-sheet) ease-out,
    clip-path var(--duration-sheet) ease-out,
    overlay var(--duration-sheet) allow-discrete,
    display var(--duration-sheet) allow-discrete;
}

.sheet[open] {
  display: flex;
  clip-path: inset(-100% -100% 0 -100%);
  transform: none;
}

.sheet:has(.panel-switch) {
  height: var(--sheet-max-height);
}

.sheet:focus {
  outline: none;
}

.sheet::backdrop {
  background: var(--scrim);
  opacity: 0;
  transition:
    opacity var(--duration-sheet) ease-out,
    overlay var(--duration-sheet) allow-discrete,
    display var(--duration-sheet) allow-discrete;
}

.sheet[open]::backdrop {
  opacity: 1;
}

@starting-style {
  .sheet[open] {
    clip-path: inset(-100% -100% 100% -100%);
    transform: translateY(100%);
  }

  .sheet[open]::backdrop {
    opacity: 0;
  }
}

.sheet--above-tabbar::backdrop {
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px));
}

.sheet--above-tabbar {
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px));
  max-height: calc(var(--sheet-max-height) - var(--tabbar) - env(safe-area-inset-bottom, 0px));
}

.sheet__handle {
  display: flex;
  flex: none;
  justify-content: center;
  cursor: grab;
  user-select: none;
  touch-action: none;
  padding: var(--space-10) 0 var(--space-6);
}

.sheet__handle span {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--switch-off);
}

.sheet__body {
  --bleed: var(--space-16);

  flex: 1;
  min-height: 0;
  padding: var(--space-4) var(--space-16) var(--space-12);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sheet:not(.sheet--above-tabbar) .sheet__body:last-child {
  padding-bottom: calc(var(--space-12) + env(safe-area-inset-bottom, 0px));
}

.sheet__header {
  display: flex;
  gap: var(--space-12);
  align-items: center;
  padding-bottom: var(--space-8);
}

.sheet__header > .button {
  margin-right: calc(-1 * var(--space-12));
}

.sheet__heading {
  display: flex;
  flex: 1;
  gap: var(--space-12);
  align-items: center;
  min-width: 0;
}

.sheet__person {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sheet__person b {
  font-size: var(--font-size-lead);
}

.sheet__person span {
  font-size: var(--font-size-badge);
  color: var(--text-2);
  overflow-wrap: anywhere;
}

.sheet__section {
  margin: 0;
  padding: var(--space-12) 0 var(--space-4);
  font-size: var(--font-size-table-head);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.sheet__footer {
  display: flex;
  flex: none;
  gap: var(--space-8);
  padding: var(--space-10) var(--space-16) calc(var(--space-10) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border-soft);
}

.sheet__footer > * {
  flex: 1;
}

@media (width >= 720px) {
  .sheet {
    inset: 0;
    width: min(480px, 100% - 40px);
    height: fit-content;
    margin: auto;
    clip-path: none;
    opacity: 0;
    transform: translateY(var(--space-16));
    transition: opacity var(--duration-sheet) ease-out, transform var(--duration-sheet) ease-out, overlay var(--duration-sheet) allow-discrete, display var(--duration-sheet) allow-discrete;
  }

  .sheet[open] {
    clip-path: none;
    opacity: 1;
  }

  @starting-style {
    .sheet[open] {
      clip-path: none;
      opacity: 0;
      transform: translateY(var(--space-16));
    }
  }

  .sheet__handle {
    display: none;
  }

  .sheet__body {
    padding-top: var(--space-12);
  }

  .sheet--anchored {
    inset: var(--sheet-top, var(--space-48)) auto auto var(--sheet-left, var(--space-48));
    width: var(--sheet-anchored-width);
    box-shadow: 0 0 0 1px var(--border), var(--shadow-lg);
  }

  .sheet--anchored::backdrop {
    background: transparent;
  }
}
