body:not(.is-mobile) {
  .modal.mod-sidebar-layout {
    backdrop-filter: var(--blur-l);

    .modal-sidebar {
      padding-top: 0;
    }
  }

  .setting-item-name {
    overflow: visible;
  }

  .modal.mod-community-modal {
    .setting-item,
    .community-modal-search-summary {
      border: none !important;
      background-color: transparent !important;
      padding: 4px 12px !important;
      gap: 0 !important;
      margin: 0;
    }

    .setting-item-name {
      padding: 0;
    }

    .community-modal-search-results-wrapper {
      border: none;
    }
  }

  .modal-close-button {
    z-index: 1;
  }

  .vertical-tab-content {
    container-type: inline-size;
  }

  @container (max-width: 480px) {
    .vertical-tab-content {
      .setting-item:not(.setting-item-heading),
      .setting-item-control {
        flex-wrap: wrap;
      }

      button {
        white-space: normal;
      }

      select,
      .dropdown,
      input {
        width: 100%;
        text-overflow: ellipsis;
      }
    }
  }
}

body:not(.is-mobile):not(.mod-windows:not(.windows-mode-off)) {
  .modal.mod-sidebar-layout:not(.mod-community-modal) {
    .vertical-tab-header,
    .vertical-tab-content {
      background-color: transparent;
    }

    .vertical-tab-header {
      border: none;
    }

    .setting-item-heading {
      border: none;
      padding: var(--side-padding) var(--side-padding) 12px;
    }
    .setting-item:not(.setting-item-heading) {
      border: none;
      gap: 8px;
      border-radius: 0;
      background-color: rgba(var(--mono-rgb-100), 0.025);
      padding: 12px var(--side-padding);
      position: relative;

      &::before {
        content: "";
        position: absolute;
        inset: 0 var(--side-padding);
        height: var(--border-width);
        background-color: var(--background-modifier-border);
        pointer-events: none;
      }
    }
    .setting-item-heading + .setting-item,
    *:not(.setting-item) + .setting-item:not(.setting-item-heading),
    .setting-item:first-child:not(.setting-item-heading) {
      border-top-right-radius: var(--radius-s) !important;
      border-top-left-radius: var(--radius-s) !important;

      &::before {
        content: none;
      }
    }
    .setting-item:has(+ .setting-item-heading),
    .setting-item:has(+ *:not(.setting-item)):not(.setting-item-heading),
    .setting-item:last-child {
      border-bottom-right-radius: var(--radius-s) !important;
      border-bottom-left-radius: var(--radius-s) !important;
    }
    .setting-item-info:has(.setting-item-name:empty) .setting-item-description {
      padding: 0;
    }
  }
}

body.is-mobile {
  &.theme-light .modal.mod-sidebar-layout {
    &,
    .vertical-tab-header,
    .vertical-tab-content {
      background-color: var(--background-secondary);
    }
  }

  .modal.mod-sidebar-layout {
    background-color: var(--background-primary);

    .modal-header,
    .modal-sidebar {
      border: none !important;
    }

    .modal-header {
      padding: var(--safe-area-inset-top) var(--side-padding) 0 !important;
      z-index: 1;
      background-color: transparent;
    }
    .modal-title {
      display: flex;
      flex-direction: row;
      align-items: center;
      max-width: 100%;
      height: var(--modal-header-height);
      overflow: visible;
      gap: 16px;
    }
    .modal-setting-back-button {
      display: flex;
      position: relative;
      top: unset;
      justify-content: center;
      align-items: center;
      order: -1;
      padding: 0;
      width: var(--modal-header-height);
      height: var(--modal-header-height);
      border-radius: var(--clickable-icon-radius);
    }
    .modal-setting-back-button-icon {
      margin-inline-end: 0;
    }

    .modal-sidebar {
      background-color: var(--modal-background);
    }

    .vertical-tab-nav-item,
    textarea,
    input[type="text"],
    input[type="number"],
    button,
    select,
    .dropdown {
      --input-height: 52px;

      height: unset;
      padding: var(--nav-item-padding) !important;
      border-bottom: none;
      position: relative;

      &:not(:last-child)::after {
        content: "";
        position: absolute;
        inset: 0 var(--side-padding);
        border-bottom: var(--border-width) solid var(--background-modifier-border);
        pointer-events: none;
      }
    }

    select,
    .dropdown {
      padding: 16px 32px 16px 20px !important;
    }

    .vertical-tab-nav-item {
      min-height: var(--input-height);
      word-break: break-word;
    }

    .vertical-tab-header-group-title {
      padding: 8px;
    }

    .vertical-tab-header-group-title,
    .setting-item-heading .setting-item-name {
      color: var(--text-faint);
      font-size: var(--font-ui-medium);
    }

    .vertical-tab-header-group-items {
      border-radius: var(--radius-m);
      background-color: var(--interactive-normal);
      overflow: hidden;
    }

    .modal-setting-nav-bar {
      padding: 8px;
    }

    .community-modal-controls .setting-item {
      background-color: transparent !important;
    }

    .community-modal-search-results-wrapper {
      border: none;
      padding: 0 var(--side-padding);
    }

    .community-modal-search-results {
      gap: 8px;
      padding: 0;
    }

    .community-item {
      border: none;
      border-radius: var(--radius-m);
      background-color: var(--interactive-normal);
      padding: var(--nav-item-padding);
    }

    .community-modal-details {
      background-color: transparent;
    }
  }
}

body.is-phone {
  .modal.mod-sidebar-layout {
    .modal-header {
      position: absolute;
    }
    .modal-title:not(:has(.modal-setting-back-button)) {
      padding-left: 8px;
      font-size: var(--inline-title-size);
      font-weight: var(--font-bold);
      margin-top: 24px;
    }
    .modal-content {
      position: absolute;
      inset: 0;
    }
    .vertical-tab-header,
    .vertical-tab-content {
      padding-top: calc(var(--safe-area-inset-top) + var(--modal-header-height) + 24px);
      padding-right: var(--side-padding);
      padding-left: var(--side-padding);
    }

    &.mod-community-modal .modal-sidebar,
    .community-modal-info {
      padding-top: calc(var(--safe-area-inset-top) + var(--modal-header-height) + 24px);
    }
  }

  &:not(.is-android:not(.material-off)) .modal.mod-sidebar-layout {
    .modal-close-button {
      top: var(--safe-area-inset-top);
      inset-inline-end: var(--side-padding);
    }

    .setting-item {
      border: none;
      position: relative;
    }
    .setting-item:not(.mod-toggle) .setting-item-info {
      padding: 0 8px;
    }

    .setting-item-heading + .setting-item:not(.mod-toggle) {
      padding-top: 0;
    }

    .setting-item.mod-toggle,
    .setting-item-control .mobile-option-setting-item {
      border-radius: var(--radius-m);
      background-color: var(--interactive-normal) !important;
      padding: var(--nav-item-padding);
    }

    .setting-item.mod-toggle:has(+ .setting-item.mod-toggle) {
      border-bottom-right-radius: 0;
      border-bottom-left-radius: 0;

      &:not(:last-child)::after {
        content: "";
        position: absolute;
        inset: 0 var(--side-padding);
        border-bottom: var(--border-width) solid var(--background-modifier-border);
        pointer-events: none;
      }
    }

    .setting-item.mod-toggle + .setting-item.mod-toggle {
      border-top-right-radius: 0;
      border-top-left-radius: 0;
    }

    .setting-item-control .clickable-icon {
      background-color: var(--interactive-normal);
      min-width: var(--input-height);
      height: var(--input-height);
    }

    .setting-item-control:not(:has(:not(button))) {
      flex-direction: column;
      gap: 0;
      border-radius: var(--radius-m);
      overflow: hidden;
    }

    .setting-item-control:not(:has(:not(button))) > button {
      border-radius: 0;
    }

    .community-modal-readme {
      padding: 0;
    }
  }
}

body.is-tablet .modal.mod-sidebar-layout {
  .modal-close-button {
    top: 8px;
    inset-inline-end: 8px;
  }

  .setting-item-heading {
    border: none;
    padding: 8px;
  }
  .setting-item:not(.setting-item-heading) {
    border-radius: 0;
    background-color: var(--interactive-normal);
    padding: 12px var(--side-padding);
  }
  .setting-item-heading + .setting-item,
  *:not(.setting-item) + .setting-item:not(.setting-item-heading),
  .setting-item:first-child:not(.setting-item-heading) {
    border-top: none !important;
    border-top-right-radius: var(--radius-s) !important;
    border-top-left-radius: var(--radius-s) !important;
  }
  .setting-item:has(+ .setting-item-heading),
  .setting-item:has(+ *:not(.setting-item)):not(.setting-item-heading),
  .setting-item:last-child {
    border-bottom-right-radius: var(--radius-s) !important;
    border-bottom-left-radius: var(--radius-s) !important;
  }
  .setting-item-info:has(.setting-item-name:empty) .setting-item-description {
    padding: 0;
  }

  textarea,
  input[type="text"],
  input[type="search"],
  input[type="number"] {
    background-color: var(--background-modifier-hover);
  }
  .vertical-tab-header-group-title {
    padding-left: 20px;
  }
  .vertical-tab-header-group-items {
    gap: 0;
    border-radius: 0;
    overflow: visible;
    background-color: transparent;
  }
  .vertical-tab-nav-item {
    display: flex;
    align-items: center;
    border-radius: 100vh;
    padding-left: var(--side-padding);
  }
  .vertical-tab-nav-item:not(:last-child)::after {
    content: none;
  }
  .vertical-tab-nav-item.is-active {
    background-color: rgba(var(--mono-rgb-100), 0.1);
    color: var(--text-accent);
  }

  button:not(.clickable-icon):not([class*="mod-"]),
  select,
  .dropdown {
    color: var(--text-accent);
    background-color: var(--background-modifier-hover);
  }
}
