:where([data-qwik-date][data-theme="light"]) {
  --foreground-color: 0, 0%, 100%;
  --background-color: 0, 0%, 0%;
  --accent-color: 240, 4.8%, 95.9%;

  --shadow-opacity: 0.25;
  --shadow-color: 0, 0%, 43%;

  --inset-shadow: inset 0 0 0 1px hsla(var(--shadow-color), var(--shadow-opacity, 0));

  --outer-shadow: 0 0 0.25rem hsla(var(--shadow-color), var(--shadow-opacity, 0));
}

:where([data-qwik-date][data-theme="dark"]) {
  --foreground-color: 0, 0%, 0%;
  --background-color: 240, 4.8%, 95.9%;
  --accent-color: 0, 0%, 20%;

  --shadow-opacity: 0.25;
  --shadow-color: 0, 0%, 100%;

  --inset-shadow: inset 0 0 0 1px hsla(var(--shadow-color), var(--shadow-opacity, 0));

  --outer-shadow: 0 0 0.25rem hsla(var(--shadow-color), 0);
}

:where([data-qwik-date]) {
  --padding-inline: 0.75rem;
  --padding-block: 0.75rem;
  --radius: 0.75rem;
  --font-size: 0.875rem;
  --icon-size: 1rem;
  --table-row-size: 2rem;

  &>* {
    @media (prefers-reduced-motion: no-preference) {
      transition: all 150ms ease-in-out;
    }
  }
}

:where(html[dir='rtl']),
:where([data-qwik-date][dir='rtl']) {
  [data-header-action] {
    transform: rotate(180deg);
  }
}

:where([data-qwik-date]):not([popover]),
:where([data-qwik-date]):popover-open {

  padding-inline: var(--padding-inline);
  padding-block: var(--padding-block);
  width: max-content;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: var(--inset-shadow), var(--outer-shadow);
  background-color: hsla(var(--foreground-color), 1);
  margin: 0;

  & header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;

    & div {
      font-size: var(--font-size);
      font-weight: 500;
      line-height: 1.25;
      color: hsla(var(--background-color), 1);
    }

    & button:has(svg) {
      background-color: transparent;
      border: none;
      margin: 0;
      padding: 0.25rem;
      display: flex;
      align-items: center;
      justify-content: center;
      color: hsla(var(--background-color), 1);
      border-radius: calc(var(--radius) - 0.4rem);

      --shadow-color: 0, 0%, 10%;
      box-shadow: inset 0 0 0 0.075rem hsla(var(--shadow-color), 0.15);

      @media (prefers-reduced-motion: no-preference) {
        transition: all 150ms ease-in-out;
      }

      &:hover {
        background-color: hsla(var(--accent-color), 1);
      }

      &:focus-visible {
        outline: none;
        box-shadow: inset 0 0 0 0.1rem hsla(var(--background-color), 0.2);
      }

      & svg {
        width: var(--icon-size);
        height: var(--icon-size);
      }
    }
  }

  & table {
    border-collapse: collapse;

    & thead>tr,
    & tbody>tr {
      display: flex;

      & th,
      & td {
        width: var(--table-row-size);
        font-size: 0.8rem;
        font-weight: 400;
        text-align: center;
        color: hsl(0, 0%, 50%);
        padding: 0;
      }

      & td {
        color: hsl(0, 0%, 75%);
      }

      & td[aria-disabled="false"] {
        color: hsla(var(--background-color), 1);
      }
    }

    &:has(th) tbody>tr:first-child {
      margin-top: 0.75rem;
    }

    & tbody {
      display: flex;
      flex-direction: column;
      gap: 0.35rem;
    }

    & tbody>tr {

      & td>button {
        background-color: transparent;
        border: 0;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: var(--font-size);
        width: var(--table-row-size);
        height: var(--table-row-size);
        border-radius: var(--radius);
        background-color: hsla(var(--foreground-color), 0);
        line-height: 1;
        color: inherit;
        outline: none;

        @media (prefers-reduced-motion: no-preference) {
          transition: background-color 150ms ease-in-out, color 150ms ease-in-out;
        }

        &:focus-visible {
          box-shadow: inset 0 0 0 0.1rem hsla(var(--background-color), 0.2);
        }

        &[data-preselected],
        &:hover {
          background-color: hsla(var(--accent-color), 1);
        }

        &[aria-selected="true"] {
          background-color: hsla(var(--background-color), 1);
          color: hsla(var(--foreground-color), 1);
        }
      }

      & td:has(span) {
        display: flex;
        align-items: center;
        justify-content: center;
        color: hsl(0, 0%, 50%);
      }
    }
  }
}

:where([data-qwik-wrapper]) {
  display: contents;

  --icon-size: 1rem;
  --min-width: 15.7rem;
  --accent-color: 240, 4.8%, 95.9%;
  --shadow-opacity: 0.25;
  --shadow-color: 0, 0%, 43%;

  & button[popovertarget] {
    width: min(100%, var(--min-width));
    height: 2.25rem;
    anchor-name: --anchor-trigger;

    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: space-between;

    border: none;
    background-color: transparent;
    box-shadow: inset 0 0 0 0.075rem hsla(var(--shadow-color), 0.15);
    padding-block: 0.5rem;
    padding-inline: 0.75rem;
    font-size: 0.875rem;
    border-radius: 0.5rem;
    color: hsla(var(--shadow-color), 1);

    & svg {
      width: var(--icon-size);
      height: var(--icon-size);
      flex: none;
    }
  }

  & [popover] {
    min-width: var(--min-width);

    border: none;
    box-sizing: border-box;
    position: absolute;
  }
}