.wrapper {
  --input-height: 3.75rem;

  display: flex;
  flex-direction: column;
  padding: var(--space);
  border-radius: var(--space);
  background-color: rgb(255 255 255 / 0.05);
  background-image: radial-gradient(
    50% 50% at 50% 50%,
    rgba(148, 88, 88, 0.48) 0%,
    rgba(148, 88, 88, 0) 100%
  );
  gap: 2rem;
  padding-block-end: 3rem;
}

.form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space);

  &::after {
    flex-basis: 1px;
    flex-grow: 1;
    order: -1;
    border-radius: 1rem;
    background-color: rgb(0 0 0 / 0.3);
    content: "";
    min-block-size: 1px;
  }

  & > :first-child {
    order: -1;
  }
}

.fieldset {
  --height: 2.5rem;
  display: grid;

  flex-basis: calc((49rem - 100%) * 999);
  flex-grow: 999;
  border: none;
  gap: calc(var(--space) / 3 * 2);
  grid-template-rows: var(--height) 1fr;
}

.fieldsetHeader {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.separator {
  align-self: stretch;
}

.unitToggle {
  --indicator-height: 3px;
  --width: calc(var(--height) * 1.9);

  position: relative;
  display: inline-grid;
  align-items: center;
  border: none;
  border-radius: 0.25rem;
  block-size: var(--height);
  font-size: var(--font-size--1);
  grid-template-columns: repeat(2, 1fr);
  inline-size: var(--width);

  &,
  & * {
    cursor: pointer;
  }

  &:focus-within {
    outline: 2px solid var(--color-orange);
    outline-offset: 4px;
  }

  &::after {
    position: absolute;
    border-radius: 99px;
    background-color: rgb(255 255 255 / 0.3);
    block-size: var(--indicator-height);
    content: "";
    inline-size: 100%;
    inset-block-end: 0;
    inset-inline-start: 0;
  }
}

.unitToggleIndicator {
  position: absolute;
  align-self: center;
  border-radius: 10px;
  background-color: white;
  block-size: var(--indicator-height);
  box-shadow: 0 0 0.125rem 0 rgba(0, 0, 0, 0.25);
  inline-size: 50%;
  inset-block-end: 0;
  inset-inline-start: 0;
  transition:
    translate 0.4s var(--ease-in-out-expo),
    background-color 0.2s ease;

  &[data-unit="rem"] {
    translate: 100%;
  }
}

.unitLabel {
  position: relative;
  z-index: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  block-size: var(--height);
  color: var(--color-foreground-secondary);
  font-weight: 600;
  grid-row: 1;
  inline-size: var(--height);
  transition:
    color 0.5s var(--ease-in-out-quint),
    border-color 0.2s ease;

  &[data-active="true"] {
    color: var(--color-foreground);
  }
}

.unitRadio {
  position: absolute;
  z-index: 2;
  block-size: 100%;
  grid-row: 1;
  inline-size: 50%;
  inset: 0;
  opacity: 0;

  &[id="unit-rem"] {
    translate: 100%;
  }
}

.legend {
  display: flex;
  align-items: center;
  color: var(--color-orange);
  font-size: var(--font-size-0);
  font-weight: 700;
  letter-spacing: 0.09em;
  line-height: 1;
  text-transform: uppercase;
}

.inputRow {
  display: grid;
  gap: calc(var(--space) / 3 * 2);
  grid-template-columns: repeat(auto-fit, minmax(11.75rem, 1fr));
}

.inputWrapper {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  font-size: var(--font-size-0);
  gap: 0.5rem;
}

.inputInner {
  display: flex;
  align-items: center;
  font-weight: 700;
  gap: 0.75rem;
}

.inputLabel {
  flex-basis: 3.5ch;
  text-transform: uppercase;
}

.input {
  --bg-hsl: 259 97% 15%;
  --shadow-hsl: 7 100% 68%;
  flex: 1;
  border: none;
  border-radius: 99px;

  appearance: none;
  background-color: hsl(var(--bg-hsl) / 0.5);
  block-size: var(--input-height);
  box-shadow: 0px 0px 2.5rem hsl(var(--shadow-hsl) / 0);
  color: var(--color-foreground);
  font-weight: 700;
  min-inline-size: 0;
  padding-inline: 1.25em 3em;
  transition:
    box-shadow 0.3s ease-in-out,
    background-color 0.3s var(--ease-in-out-circ);

  &:is(:hover, :focus) {
    background-color: hsl(var(--bg-hsl) / 0.9);
  }

  &:focus {
    box-shadow: 0px 0px 2.5rem hsl(var(--shadow-hsl) / 0.8);
    outline: none;
  }

  &::-webkit-inner-spin-button,
  &::-webkit-outer-spin-button {
    margin: 0;
    appearance: none;
  }

  @supports (-moz-appearance: textfield) {
    -moz-appearance: textfield;
  }
}

.inputUnit {
  position: absolute;
  color: var(--color-foreground-secondary);
  font-size: var(--font-size-0);
  font-weight: 500;
  inset-inline-end: 1em;
  pointer-events: none;
  user-select: none;
}

.inputDescription {
  color: var(--color-foreground-secondary);
  font-size: var(--font-size--1);
  font-weight: 500;
}

.output {
  --min-height: 4.5rem;
  display: flex;
  flex-wrap: wrap;
  border-radius: calc(var(--min-height) / 2);
  background-color: rgb(255 255 255 / 0.1);
  font-size: var(--font-size-0);
  line-height: 1.25;

  min-block-size: var(--min-height);
  white-space: normal;
}

.outputCSS {
  display: flex;
  flex-basis: 40ch;
  flex-grow: 999;
  align-items: center;
  padding: 1rem;
  font-weight: 700;
  padding-block: 1.25em;
  padding-inline: 1.75em;
  user-select: all;
}

.copyButtonWrapper {
  position: relative;
  display: flex;
  flex-grow: 1;
  flex-shrink: 0;
  align-items: center;
  align-self: stretch;
  justify-content: center;
}

.copyButton {
  --offset: 0.25rem;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: calc(var(--min-height) / 2);
  background-color: var(--color-orange);
  block-size: 100%;
  color: var(--color-purple);
  font-size: var(--font-size-0);
  font-weight: 700;
  inline-size: 100%;
  line-height: 1;
  min-block-size: var(--input-height);
  padding-inline: 2rem;
  transition:
    background-color 0.2s ease-in-out,
    box-shadow 0.3s ease-in-out;

  & ::selection {
    background: hsl(var(--color-purple-hsl) / 0.4);
  }

  &:hover {
    box-shadow: 0px 0px 2rem hsl(var(--color-orange-hsl) / 0.7);
  }
}

.copyButtonTextPlaceholder {
  opacity: 0;
}

.copyButtonText {
  position: absolute;
  display: block;
}

.copySuccess {
  position: absolute;
  z-index: 2;
  display: block;
  display: grid;
  border-radius: 99px;
  background-image: radial-gradient(
    var(--color-orange) 20%,
    hsl(var(--color-orange-hsl) / 0) 100%
  );
  inline-size: 3rem;
  place-content: center;
  pointer-events: none;
  user-select: none;

  & svg {
    --size: 2rem;
    block-size: var(--size);
    inline-size: var(--size);
  }
}

.errors {
  padding: 1.5em;
  border-radius: calc(var(--input-height) / 2);
  background-color: rgb(222 0 0 / 0.2);
  font-size: var(--font-size-0);

  & ul {
    margin-block-start: 0.5em;
    margin-inline-start: 1.25em;

    & li + li {
      margin-block-start: 0.5em;
    }
  }
}

.liveExample {
  margin-block-end: var(--space);
  margin-block-start: 1rem;
  transition: translate 0.4s var(--ease-out-quad);
  transition-delay: 0.1s;
  translate: 0 calc(-1rem - 1em);

  &[open] {
    transition-delay: 0s;
    translate: 0 0;

    &::details-content {
      block-size: auto;

      @starting-style {
        block-size: 0;
      }
    }
  }

  & summary {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    border-radius: 999rem;
    background: var(--color-orange);
    color: var(--color-purple);
    cursor: pointer;
    font-size: var(--font-size--1);
    font-weight: 700;
    gap: 0.5em;
    inline-size: max-content;
    margin-block-end: -1em;
    margin-inline: auto;
    padding-block: 0.5em;
    padding-inline: 1em;

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

    &::before {
      display: block;
      border-width: 0.5em 0.375em 0;
      border-style: solid;
      border-color: transparent;
      block-size: 0;
      border-block-end-color: var(--color-purple);
      border-block-start-color: var(--color-purple);
      content: "";
      inline-size: 0;
      transition: scale 0.4s var(--ease-in-out-circ);
    }
  }

  &[open] summary::before {
    scale: 1 -1;
  }

  &::details-content {
    --transition: 0.4s var(--ease-in-out-cubic);

    overflow: hidden;
    border-radius: var(--space);
    block-size: 0;
    interpolate-size: allow-keywords;
    transition:
      block-size var(--transition),
      content-visibility var(--transition) allow-discrete;

    @starting-style {
      block-size: 0;
    }
  }

  & p {
    padding: var(--space);
    border-radius: var(--space);
    background: rgb(255 255 255 / 0.05);
    font-size: var(--variable-value);
    line-height: 1.4;

    &:focus-visible {
      outline-offset: -2px;
    }
  }
}
