details[data-control="select"] {
  --select-height: 30px;
  --select-font-size: 13px;
  --select-font-weight: 500;
  --select-radius: 6px;
  --select-option-padding-inline-start: 6px;
  --select-option-padding-inline-end: 24px;
  --select-option-justify: flex-start;
  --select-option-text-align: left;

  position: relative;

  &[data-size="md"] {
    --select-height: 34px;
    --select-font-size: 14px;
  }

  &[data-align="end"] {
    --select-option-justify: flex-end;
    --select-option-text-align: right;
  }

  &[data-width="full"] {
    display: block;
    width: 100%;

    > summary {
      justify-content: space-between;
      width: 100%;
    }

    > div[role="listbox"] {
      width: 100%;
      min-width: 0;
      max-width: none;
    }
  }

  &[data-has-icon="true"] {
    --select-option-padding-inline-start: 22px;
  }

  > summary {
    position: relative;
    display: inline-flex;
    width: 100%;
    height: var(--select-height);
    align-items: center;
    gap: 6px;
    padding: 0 28px 0 12px;
    color: var(--ink);
    background: var(--bg-raised);
    border: 0.5px solid var(--border-strong);
    border-radius: var(--select-radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    font: inherit;
    font-size: var(--select-font-size);
    font-weight: var(--select-font-weight);
    line-height: 1;
    list-style: none;
    user-select: none;

    &::-webkit-details-marker {
      display: none;
    }

    &::after {
      position: absolute;
      top: 50%;
      right: 11px;
      width: 6px;
      height: 6px;
      border: solid var(--ink-muted);
      border-width: 0 1.5px 1.5px 0;
      content: "";
      pointer-events: none;
      transform: translateY(-65%) rotate(45deg);
    }

    &:hover {
      background: var(--bg-sunken);
    }

    &:has(> svg),
    details[data-align="end"] & {
      justify-content: flex-end;
    }

    &:has(> svg) {
      overflow: hidden;
      padding-left: 30px;
      padding-right: 31px;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    > svg {
      position: absolute;
      top: 50%;
      left: 11px;
      z-index: 1;
      display: block;
      width: 14px;
      height: 14px;
      fill: none;
      stroke: var(--ink-muted);
      stroke-linecap: round;
      stroke-linejoin: round;
      stroke-width: 1.5;
      pointer-events: none;
      transform: translateY(-50%);
    }
  }

  &[open] > summary::after {
    transform: translateY(-35%) rotate(225deg);
  }

  > :is(ul, div[role="listbox"]) {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 200;
    min-width: 100%;
    max-height: 330px;
    padding: 6px;
    margin: 0;
    overflow-y: auto;
    background: var(--bg-raised);
    border: 0.5px solid var(--border);
    border-radius: var(--rad);
    box-shadow: var(--shadow);
    list-style: none;
  }

  [role="option"] {
    position: relative;
    display: flex;
    width: 100%;
    min-height: var(--select-height);
    align-items: center;
    justify-content: var(--select-option-justify);
    padding: 6px var(--select-option-padding-inline-end) 6px var(--select-option-padding-inline-start);
    color: var(--ink);
    background: transparent;
    border: 0;
    border-radius: calc(var(--select-radius) - 1px);
    cursor: pointer;
    font: inherit;
    font-size: var(--select-font-size);
    font-weight: var(--select-font-weight);
    text-align: var(--select-option-text-align);
    text-decoration: none;
    white-space: nowrap;

    &:hover {
      background: var(--bg-sunken);
      text-decoration: none;
    }

    &[aria-selected="true"] {
      font-weight: 600;

      &::after {
        position: absolute;
        top: 50%;
        right: 5px;
        width: 6px;
        height: 10px;
        border: solid var(--clay);
        border-width: 0 1.5px 1.5px 0;
        content: "";
        transform: translateY(-58%) rotate(45deg);
      }
    }

    &[aria-disabled="true"] {
      color: var(--ink-faint);
      cursor: not-allowed;

      &:hover {
        background: transparent;
      }
    }
  }
}
