body:is(.layout-cupertino, .layout-macos) .modal.mod-sidebar-layout {
  --background-modifier-hover: rgba(var(--mono-rgb-100), 0.03);
  border: none;
}

body:is(.layout-cupertino, .layout-macos):not(.is-phone) .modal.mod-sidebar-layout:not(.mod-community-modal),
body:is(.layout-cupertino, .layout-macos).is-phone .modal.mod-sidebar-layout {
  .setting-item:not(.setting-item-heading) {
    border: none;
    background-color: var(--background-modifier-hover);
    position: relative;

    &::after {
      position: absolute;
      inset: auto var(--side-padding) 0;
      background-color: var(--background-modifier-border);
      height: var(--border-width);
      pointer-events: none;
      content: "";
    }
  }

  .setting-item.setting-item-heading + .setting-item,
  *:not(.setting-item) + .setting-item,
  .setting-item:not(.setting-item-heading):first-child {
    border-top-left-radius: var(--radius-m);
    border-top-right-radius: var(--radius-m);
  }
  .setting-item:not(.setting-item-heading):has(+ .setting-item.setting-item-heading, + div:not(.setting-item)),
  .setting-item:not(.setting-item-heading):last-child {
    border-bottom-left-radius: var(--radius-m);
    border-bottom-right-radius: var(--radius-m);

    &::after {
      content: none;
    }
  }

  .installed-plugins-container {
    padding-top: 0;
    border-top: none;
  }
}
body:is(.layout-cupertino, .layout-macos):not(.is-mobile) .modal.mod-sidebar-layout:not(.mod-community-modal) {
  background-color: var(--background-primary);

  .horizontal-tab-nav-item,
  .vertical-tab-nav-item,
  .vertical-tab-header-group-title {
    padding: 4px 8px;
  }

  .setting-item-heading.setting-item {
    padding: calc(var(--side-padding) * var(--density-modifier)) var(--side-padding) calc(12px * var(--density-modifier));
  }
  .setting-item {
    padding: calc(12px * var(--density-modifier)) var(--side-padding);
  }
}

body:is(.layout-cupertino, .layout-macos):not(.mobile-stable).is-phone .modal.mod-sidebar-layout,
body:is(.layout-cupertino, .layout-macos):not(.mobile-stable).is-tablet .modal.mod-sidebar-layout:not(.mod-community-modal) {
  .vertical-tab-header-group-items {
    border-radius: var(--radius-m);
    background-color: var(--background-primary);
    overflow: hidden;
  }
  .vertical-tab-nav-item {
    position: relative;
    border-bottom: none;
    padding: var(--nav-item-padding);
    height: unset;
  }
  .vertical-tab-nav-item:not(:last-child)::after {
    position: absolute;
    inset: auto var(--side-padding) 0;
    background-color: var(--background-modifier-border);
    height: var(--border-width);
    pointer-events: none;
    content: "";
  }

  .vertical-tab-header-group-title,
  .setting-item-heading .setting-item-name {
    font-size: var(--font-ui-medium);
    color: var(--text-faint);
  }
  .setting-item {
    padding: calc(16px * var(--density-modifier)) var(--side-padding);
  }
  .setting-item:not(.setting-item-heading) {
    background-color: var(--interactive-normal);
  }

  .mobile-option-setting-item {
    margin-inline: var(--side-padding);
    min-height: var(--input-height);
    gap: 8px;
  }
  .mobile-option-setting-item-remove-icon svg.svg-icon,
  .mobile-option-setting-item-add-icon svg.svg-icon {
    fill: currentColor;

    path {
      stroke: var(--mobile-sidebar-background);
    }
  }
}
body:is(.layout-cupertino, .layout-macos):not(.mobile-stable).is-phone .modal.mod-sidebar-layout {
  .modal-header {
    position: absolute;
    z-index: 1;
    padding-top: calc(var(--safe-area-inset-top) + 12px);
  }
  .modal-header::before {
    position: absolute;
    top: 0;
    inset-inline: 0;
    z-index: -1;
    mask: linear-gradient(to bottom, hsl(0, 0%, 0%) 0%, hsla(0, 0%, 0%, 0.99) 18.4%, hsla(0, 0%, 0%, 0.963) 33.7%, hsla(0, 0%, 0%, 0.92) 46.4%, hsla(0, 0%, 0%, 0.864) 56.7%, hsla(0, 0%, 0%, 0.796) 64.8%, hsla(0, 0%, 0%, 0.72) 71.2%, hsla(0, 0%, 0%, 0.637) 76.1%, hsla(0, 0%, 0%, 0.55) 79.9%, hsla(0, 0%, 0%, 0.46) 82.8%, hsla(0, 0%, 0%, 0.37) 85.2%, hsla(0, 0%, 0%, 0.283) 87.3%, hsla(0, 0%, 0%, 0.2) 89.6%, hsla(0, 0%, 0%, 0.124) 92.3%, hsla(0, 0%, 0%, 0.056) 95.6%, hsla(0, 0%, 0%, 0) 100%);
    background-color: var(--mobile-sidebar-background);
    height: calc(var(--safe-area-inset-top) + var(--view-header-height) + 32px);
    pointer-events: none;
    content: "";
  }
  .modal-setting-back-button {
    inset-inline-start: var(--safe-area-inset-side);
    height: fit-content;
  }

  .modal-content {
    position: absolute;
    inset: 0;
  }
  .modal-content .community-modal-controls,
  .modal-content .community-modal-info {
    background-color: var(--mobile-sidebar-background);
    padding-top: calc(var(--safe-area-inset-top) + var(--modal-header-height) + 24px);
  }

  .vertical-tab-header,
  .vertical-tab-content {
    padding-top: calc(var(--safe-area-inset-top) + var(--modal-header-height) + 24px);
    padding-inline: var(--safe-area-inset-side);
  }
  .vertical-tab-header-group:first-child {
    padding-top: 0;
  }
  .vertical-tab-header-group-title {
    display: none;
  }

  .setting-item:not(.setting-item-heading) .setting-item-control {
    button:not(.clickable-icon),
    select,
    .dropdown,
    textarea,
    input:is([type="text"], [type="email"], [type="password"], [type="number"]) {
      padding: 0;
      border-radius: 0;
      height: unset;
      justify-content: flex-start;
      background-color: transparent;
      box-shadow: none;
      border: none;

      &:not(input) {
        color: var(--text-accent);
      }

      &:not([class*="mod-"]) {
        font-weight: var(--font-normal);
      }
    }

    .search-input-container {
      height: unset;

      input {
        border-radius: 0;
        box-shadow: none;
        border: none;
      }
    }
  }

  .modal-close-button {
    inset-inline-end: var(--safe-area-inset-side) !important;
  }

  .community-modal-details {
    background-color: var(--mobile-sidebar-background);

    > div {
      transition: var(--anim-duration-moderate);

      @starting-style {
        opacity: 0;
      }
    }
  }
  .community-modal-controls {
    gap: 0;
  }
  .community-modal-controls .search-input-container + button {
    flex: 1;
  }
}
body:is(.layout-cupertino, .layout-macos):not(.mobile-stable).is-tablet .modal.mod-sidebar-layout {
  .setting-item-control {
    --interactive-normal: var(--background-modifier-hover);
    --dropdown-background: var(--interactive-normal);
    --background-modifier-form-field: var(--interactive-normal);
  }
}
