
.sheet-scrim,
.sheet-grip,
.sheet-close,
.sheet-label { display: none; }
.sheet-head { display: contents; }
.sheet-title { position: absolute; inline-size: 1px; block-size: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 991.98px) {
  .sheet-scrim {
    position: fixed;
    inset: 0;
    z-index: 101;
    display: block;
    background-color: rgb(0 0 0 / .32);
    opacity: 0;
    visibility: hidden;
    -webkit-tap-highlight-color: transparent;
    transition: opacity .45s var(--ease-out), visibility 0s linear .45s;
  }
  .masthead:has(> :is(.palette-panel, .audio-panel)[open]:not([data-closing])) > .sheet-scrim {
    opacity: 1;
    visibility: visible;
    transition: opacity .55s var(--ease-out), visibility 0s;
  }

  .palette-panel,
  .audio-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    inline-size: min(100%, 640px);
    max-block-size: calc(100dvh - 24px);
    margin-inline: auto;
    padding: 0 var(--section-pad-x) calc(var(--section-pad-x) + env(safe-area-inset-bottom, 0px));
    border: 0;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -20px 60px -24px rgb(0 0 0 / .35);
  }

  .sheet-head {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    padding-block-start: 10px;
    touch-action: none;
    cursor: grab;
    -webkit-user-select: none;
    user-select: none;
  }
  .sheet-head:active { cursor: grabbing; }
  .sheet-grip {
    grid-column: 1 / -1;
    justify-self: center;
    display: block;
    inline-size: 40px;
    block-size: 5px;
    margin-block-end: 14px;
    border-radius: 3px;
    background-color: color-mix(in srgb, var(--ink) 22%, transparent);
  }
  .sheet-title {
    position: static;
    inline-size: auto;
    block-size: auto;
    margin: 0;
    overflow: visible;
    clip-path: none;
    font-size: var(--text-h5);
    font-weight: 700;
    letter-spacing: .04em;
    line-height: 1.4;
  }
  .sheet-close {
    display: grid;
    place-items: center;
    inline-size: 44px;
    block-size: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background-color: color-mix(in srgb, var(--ink) 7%, transparent);
    color: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .3s var(--ease-out), scale .25s var(--ease-out);
  }
  .sheet-close:hover { background-color: color-mix(in srgb, var(--ink) 12%, transparent); }
  .sheet-close:active { scale: .9; }
  .sheet-close:focus-visible { outline: 1px solid currentColor; outline-offset: 3px; }
  .sheet-close svg { transition: rotate .45s var(--ease-out); }
  .sheet-close:hover svg { rotate: 90deg; }

  .sheet-label {
    grid-column: 1 / -1;
    display: block;
    margin: 0 0 calc(var(--gap-block) * -.5);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: .12em;
    line-height: 1.4;
    color: color-mix(in srgb, var(--ink) 55%, transparent);
  }
  .sheet-label ~ .sheet-label { margin-block-start: calc(var(--gap-heading) - var(--gap-block)); }
}

@media (hover: none) and (pointer: coarse) {
  .palette-panel,
  .audio-panel { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet-scrim,
  .sheet-close,
  .sheet-close svg { transition: none !important; }
}
