.modern-form {
  cursor: default;

  &, & * {
    -webkit-user-select: none;
    user-select: none;
  }

  :not(input, textarea) {
    cursor: default;
  }

  input:not([type="radio"], [type="checkbox"]), textarea {
    -webkit-user-select: text;
    user-select: text;
  }

  .field {
    min-width: 0;

    > .label {
      display: grid;
      gap: 0.6rem;

      > span {
        padding-inline: 0.2rem;
        font-size: 1.3rem;
        font-weight: 600;
        color: var(--color-gray);

        > small {
          margin-left: 0.4rem;
          font-size: 1.2rem;
          font-weight: 400;
        }
      }

      > button {
        justify-content: flex-start;
      }

      &:has(> select) {
        position: relative;

        &::after {
          content: "";
          position: absolute;
          right: 1.6rem;
          bottom: 1.5rem;
          width: 0.6rem;
          height: 0.6rem;
          border-right: 1.5px solid var(--color-gray);
          border-bottom: 1.5px solid var(--color-gray);
          rotate: 45deg;
          pointer-events: none;
        }
      }
    }

    > p {
      margin-top: 0.6rem;
      padding-inline: 0.2rem;
      font-size: 1.2rem;
      line-height: 1.4;
      color: var(--color-gray);
    }
  }
}

:is(textarea, input:not([type]), input:is([type="text"], [type="search"], [type="email"], [type="password"], [type="tel"], [type="url"], [type="number"])) {
  cursor: text;

  &:is(:disabled, [inert], [inert] *) {
    cursor: default;
  }
}

.form-control, .modern-form .field > .label > button {
  appearance: none;
  box-sizing: border-box;
  min-width: 0;
  width: 100%;
  height: 3.6rem;
  border: 1px solid var(--toolbar-border-color);
  border-radius: 100vmax;
  padding-inline: 1.2rem;
  background: transparent;
  box-shadow: none;
  font-size: 1.6rem;

  &:is(:disabled, [readonly]) {
    color: black;
    -webkit-text-fill-color: black;
  }
}

select.form-control {
  display: block;
  min-height: 3.6rem;
  line-height: normal;
  padding-right: 3.6rem;
}

.form-control:focus-visible, .modern-form :is(button, input[type="checkbox"]):focus-visible {
  outline: 2px solid var(--color-blue);
  outline-offset: 2px;
}

:is(input[readonly], textarea[readonly], [aria-readonly="true"]):focus-visible {
  outline: 2px solid var(--color-gray);
  outline-offset: 2px;
}

.game-search {
  border-bottom: 0.1rem solid var(--toolbar-border-color);
  padding: 0.8rem;
  display: flex;
  align-items: center;

  &:has(input:disabled) {
    opacity: 0.5;
  }


  .wrapper {
    position: relative;
    margin-inline: auto;
    width: 100%;
    isolation: isolate;


    svg {
      z-index: 1;
      position: absolute;
      top: 0;
      bottom: 0;
      margin-inline: 0.1rem;
      padding: 0.6rem;
      aspect-ratio: 1 / 1;
      width: auto;
      height: 100%;

      &.loupe {
        left: 0;
        fill: var(--color-gray);
        pointer-events: none;
      }

      &.clear {
        right: 0;

        &:is(input:placeholder-shown ~ *) {
          display: none;
        }
      }
    }


    input {
      --size: 3.6rem;
      display: block;
      padding-inline: calc(var(--size));
      width: 100%;
      height: var(--size);
      line-height: normal;

      &::placeholder {
        font: inherit;
      }
    }
  }
}

.person-details {
  > main {
    padding: 1.6rem;
    display: grid;
    align-content: start;
    gap: 2.4rem;

    > div > h2 {
      margin: 0;
      font-size: 2.1rem;
      font-weight: 600;
      line-height: 1.3;
    }
  }

  .fields, .settings, :is(.permissions, .security):not([hidden]) {
    display: grid;
    gap: 1.2rem;
  }

  .fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));

    > * { grid-column: 1 / -1; }
    > :is(.firstname, .lastname) { grid-column: auto; }
    .field > .label > span { padding-inline: 0; }
  }
}

.modern-form .statistics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.2rem;

  > h2 {
    grid-column: 1 / -1;
  }

  > div {
    display: grid;
    align-content: center;
    gap: 0.2rem;
    text-align: center;
    border-radius: 1.6rem;
    padding: 0.8rem 1.2rem;
    background: var(--toolbar-background-color);
    overflow-wrap: anywhere;

    > span:first-child {
      font-size: 2rem;
      font-variant-numeric: tabular-nums;
    }

    > span:last-child {
      min-block-size: 2lh;
      font-size: 1.2rem;
      color: var(--color-gray);
    }
  }
}


fieldset.segments {
  display: flex;
  min-width: 0;
  margin: 0;
  border: none;
  border-radius: 100vmax;
  padding: 0.3rem;
  gap: 0.3rem;
  background: var(--toolbar-background-color);

  &:has(input:disabled) {
    background: var(--viewkit-light-background);
    box-shadow: inset 0 0 0 1px var(--toolbar-border-color);
  }

  > label {
    position: relative;
    display: flex;
    flex: 1;
    min-width: 0;

    > input {
      position: absolute;
      opacity: 0;
      width: 1px;
      height: 1px;
    }

    > span {
      display: grid;
      place-items: center;
      width: 100%;
      box-sizing: border-box;
      height: 3rem;
      border-radius: 100vmax;
      padding: 0 0.4rem;
      font-size: 1.4rem;
      line-height: 1.05;
      text-align: center;
      font-weight: 500;
      overflow-wrap: anywhere;
    }

    > input:checked + span {
      background: var(--viewkit-light-background);
      box-shadow: inset 0 0 0 1px var(--toolbar-border-color);
      color: var(--active-color);
    }

    > input:focus + span {
      outline: 2px solid var(--color-blue);
      outline-offset: 2px;
    }

    > input:disabled + span {
      color: var(--color-gray);
    }

    > input:disabled:checked + span {
      background: var(--toolbar-background-color);
      box-shadow: none;
      color: inherit;
    }
  }
}

.switch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 4.8rem;
  gap: 1.2rem;

  &.compact {
    justify-content: flex-start;
    min-height: 3.6rem;
    gap: 0.8rem;
    font-size: 1.3rem;

    > span { text-box: normal; }
  }

  input {
    appearance: none;
    flex-shrink: 0;
    width: 4.4rem;
    height: 2.6rem;
    border-radius: 100vmax;
    background: var(--toolbar-border-color);
    padding: 0.3rem;
    &::before { content: ''; display: block; width: 2rem; height: 2rem; border-radius: 50%; background: white; }
    &:checked { background: var(--color-blue); }
    &:checked::before { translate: 1.8rem; }
    &:disabled { opacity: 0.6; }
    &:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; }
  }
}

.email-code-sheet {
  width: 100%;
  max-width: 44rem;
  max-height: var(--app-sheet-height);

  &[shown] {
    transition: none;
  }

  @media (width >= 680px) and (height >= 620px) {
    &:not([hidden]) {
      border-radius: var(--sheet-border-radius);
      --viewkit-sheet-offset-y: var(--viewkit-sheet-centered-offset-y);
    }
  }

  button[type="submit"]:not(:disabled) {
    color: var(--color-blue);
  }

  > form {
    display: grid;
    align-content: start;
    gap: 1.6rem;
    padding: 1.6rem;
  }
}
