@layer components {
  .dialog {
    width: min(34rem, calc(100vw - 2 * var(--space-md)));
    max-height: calc(100dvh - 2 * var(--space-xl));
    margin: auto;
    padding: 0;
    color: var(--ink-body);
    text-align: start;
    white-space: normal;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--menu-shadow);

    &[open] {
      display: flex;
      flex-direction: column;
    }

    &::backdrop {
      background: var(--backdrop);
    }
  }

  .dialog--wide {
    width: min(44rem, calc(100vw - 2 * var(--space-md)));
  }

  .dialog__form {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .dialog__head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-md) var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--hairline);
  }

  .dialog__title {
    font-size: var(--text-heading);
    font-weight: var(--weight-display);
    line-height: var(--control-height);
    color: var(--navy);
  }

  .dialog__subject {
    color: var(--ink-muted);
  }

  .dialog__alert {
    font-weight: var(--weight-emphasis);
    color: var(--ink);
  }

  .dialog__close {
    display: grid;
    flex: none;
    place-items: center;
    width: var(--control-height);
    height: var(--control-height);
    color: var(--ink-muted);
    border-radius: var(--radius-md);

    &:hover {
      color: var(--ink);
      background: var(--sheet-head);
    }

    & .icon {
      width: 1.25rem;
      height: 1.25rem;
    }
  }

  .dialog__body {
    display: grid;
    gap: var(--space-lg);
    padding: var(--space-lg);
    overflow-y: auto;
  }

  .dialog__text {
    max-width: 60ch;
    line-height: 1.5;
  }

  .dialog__foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: var(--sheet-head);
    border-top: 1px solid var(--hairline);
  }

  .dialog__foot-start {
    margin-right: auto;
  }

  @media (max-width: 720px) {
    .dialog,
    .dialog--wide {
      width: 100%;
      max-width: 100%;
      max-height: 92dvh;
      margin: auto 0 0;
      border-bottom: 0;
      border-radius: var(--radius-md) var(--radius-md) 0 0;
    }

    .dialog__foot {
      padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom));
    }

    .dialog__foot .button {
      flex: 1;
      justify-content: center;
    }
  }
}
