.super-example {
  --color-bg-code: var(--quote-bg);
  --color-text: var(--fg);
  --color-text-code: var(--fg);
  --color-text-meta: var(--fg);
  --label-size: 1rem;
  --space-2xs: clamp(0.5625rem, 0.5362rem + 0.1316vi, 0.625rem);
  --space-s: clamp(1.125rem, 1.0724rem + 0.2632vi, 1.25rem);

  display: grid;
  grid-template-rows: auto auto;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  overflow: hidden;
  grid-gap: 3px;
  grid-template-areas:
    'query query'
    'input result';

  &[data-layout~='no-labels'] {
    header > label {
      display: none;
    }
  }

  &[data-layout~='stacked']:not(.no-input) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'query'
      'input'
      'result';
  }

  &.no-input {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'query'
      'result';
    .input {
      display: none;
    }
  }

  & > * {
    background-color: var(--color-bg-code);
    color: var(--color-text-code);
  }

  & label {
    font-size: var(--label-size);
    padding-inline: var(--space-s);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 1.5px;
  }

  & .editor {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: min-content auto;

    & header {
      align-items: end;
      height: fit-content;
    }
  }

  & .query {
    grid-area: query;
  }

  & .input {
    grid-area: input;
  }

  & .result {
    grid-area: result;
  }

  & .cm-editor {
    font-size: 0.9em;
    background: var(--color-bg-code);
    color: var(--color-text-code);
  }

  & .cm-line {
    padding: 0 var(--space-s);
  }

  & .cm-scroller {
    overflow: auto;
    max-height: 40rem;
    scrollbar-color: var(--color-text-meta) var(--color-bg-code);
    padding-block: 0.2em;
  }

  & .cm-selectionBackground {
    background: var(--sidebar-non-existant) !important;
  }

  & .cm-focused,
  & .editor:has(.cm-focused) {
    outline: none;
    background: var(--quote-border);
  }

  /* The super flags of an example, which differ from the defaults, follow
     the Result label.  The header leaves room for the tools on the right. */
  & .result header {
    padding-inline-end: 9rem;
  }

  & .result header > .flags {
    margin-inline-start: 0.5em;
    vertical-align: middle;
  }

  /* The gear button and the COPY button, which copy-button.js adds after
     it, sit where the COPY button sits in other panels, so COPY doesn't
     move and the gear makes room when COPY changes to COPIED.  These sizes
     are in rem, like the COPY button's. */
  & .result {
    position: relative;
  }

  & .result > .tools {
    align-items: center;
    display: flex;
    gap: 0.6rem;
    position: absolute;
    right: 0.5rem;
    top: 0.5rem;
    z-index: 1;

    & > .copy-button {
      position: static;
    }
  }

  /* An open settings panel starts below the tools, including in the
     no-labels layout, where the header is otherwise empty. */
  & .result:has(> .settings:not([hidden])) > header {
    min-height: 3.4rem;
  }

  /* Sizes are in em, not rem, since mdBook's root font size is 10px. */
  & .flags,
  & .settings-button {
    background: none;
    border: 1px solid currentColor;
    color: var(--color-text-code);
    cursor: pointer;
    font-size: 0.85em;
    line-height: 1.2;
  }

  & .flags {
    background: color-mix(in srgb, var(--fg) 9%, transparent);
    border: none;
    font-family: var(--mono-font);
    padding: 0.1em 0.5em;
  }

  /* The gear button shows when the pointer is over the Result panel or
     the keyboard focus is in it, when its panel is open, and when the
     reader has changed the flags.  Devices without hover always show it. */
  & .settings-button {
    border: none;
    display: inline-flex;
    opacity: 0;
    padding: 0;
    transition: opacity 300ms;

    & svg {
      height: 1.4em;
      width: 1.4em;
    }
  }

  & .result:hover .settings-button,
  & .result:has(:focus-visible) .settings-button,
  &.modified .settings-button,
  & .settings-button[aria-expanded='true'] {
    opacity: 1;
  }

  @media (hover: none) {
    & .settings-button {
      opacity: 1;
    }
  }

  & .settings-button:hover,
  & .flags:hover {
    color: var(--footnote-highlight);
  }

  & .result:has(> .settings:not([hidden])) {
    grid-template-rows: min-content min-content auto;
  }

  /* The settings panel has a tint of pink, mixed with the panel's own
     background so it suits every theme. */
  & .settings {
    background: color-mix(in srgb, hotpink 14%, var(--color-bg-code));
    border-block: 1px solid var(--quote-border);
    display: flex;
    flex-wrap: wrap;
    font-size: 0.85em;
    gap: 0.4em 1.5em;
    padding: 0.6em var(--space-s);

    &[hidden] {
      display: none;
    }

    & code {
      font-size: 1em;
    }

    & .command {
      background: none;
      flex-basis: 100%;
      padding: 0;
    }

    /* Each kind's options wrap beside its legend, not below it. */
    & fieldset {
      border: none;
      display: flex;
      flex-basis: 100%;
      gap: 0.5em;
      margin: 0;
      padding: 0;
    }

    /* Floated so it's a flex item and not drawn in the fieldset's border. */
    & legend {
      flex: none;
      float: left;
      font-weight: 600;
      padding: 0;
      width: 7.5em;
    }

    & .options {
      display: flex;
      flex: 1;
      flex-wrap: wrap;
      gap: 0.3em 0.8em;
      min-width: 0;
    }

    & input {
      accent-color: var(--links);
      height: 1em;
      margin: 0;
      width: 1em;
    }

    & label {
      align-items: center;
      cursor: pointer;
      display: inline-flex;
      font-size: inherit;
      font-weight: normal;
      gap: 0.35em;
      letter-spacing: normal;
      padding: 0;
      text-transform: none;
    }

    & label code {
      background: none;
      padding: 0;
    }

    & .reset {
      background: none;
      border: 1px solid currentColor;
      color: var(--color-text-code);
      cursor: pointer;
      font: inherit;
      padding: 0.1em 0.6em;
    }

    & .reset[hidden] {
      display: none;
    }
  }
}
