@if $trans == 'true' { $panel_bg:   if($variant == 'light', rgba(white, $panel_opacity), rgba(black, $panel_opacity)); }

//
// GNOME Terminal, MATE Terminal
//
.mate-terminal {
  notebook {
    > header.top {
      > tabs > tab {
        border-top: 1px solid transparent;
      }
    }
  }
}

terminal-window {
  &.background.csd {
    border-radius: 0 0 0 0;
  }

  decoration {
    border-radius: $wm_radius $wm_radius 0 0;
  }

  notebook {
    button.flat.toggle.popup {
      min-height: 28px;
      min-width: 28px;
      margin: -2px;
    }
  }

  &.background.csd.maximized { border-radius: 0 0 0 0; } // Fixed gnome 3.32 issue: Unable to restore window size after maximization
}

window.background.csd { // gnome-terminal 3.32 setting
  > box.vertical > box.horizontal > frame {
    > border {
      border-width: 0 1px 0 0;
    }

    > scrolledwindow > viewport.frame {
      list {
        border-bottom-left-radius: $wm_radius;
      }
    }
  }

  > box.vertical > box.horizontal > stack {
    > widget > notebook.frame {
      border-width: 0;

      > stack {
        border-bottom-right-radius: $wm_radius;
      }
    }
  }
}

//
// Nautilus
//
$nautilus_radius: $wm_radius + 1px;
$nautilus_sidebar_size: $sidebar_size;
$nautilus_borders_color: if($variant=='light', darken(rgba($dark_sidebar_bg, 1), 12%), $header_border);

$nautilus_header_image: image($header_bg);
$nautilus_header_borders_image: image($header_border);
$nautilus_actionbar_image: image($dark_header_bg);
$nautilus_actionbar_borders_image: image($header_border);
$dialog_header_image: image($dark_header_bg);
$dialog_header_borders_image: image($header_border);
$nautilus_bg_image: image($dark_sidebar_bg);
$nautilus_sidebar_image: image($dark_sidebar_bg);


@if $nautilus_style == 'stable' {
  $nautilus_sidebar_image: linear-gradient(90deg, $dark_sidebar_bg 0%,
                                                  $dark_sidebar_bg $nautilus_sidebar_size,
                                                  rgba($dark_sidebar_bg, 0) $nautilus_sidebar_size,
                                                  rgba($dark_sidebar_bg, 0) 100%);

  $nautilus_bg_image: linear-gradient(90deg, $dark_sidebar_bg 0%,
                                             $dark_sidebar_bg $nautilus_sidebar_size,
                                             $nautilus_borders_color $nautilus_sidebar_size,
                                             $nautilus_borders_color ($nautilus_sidebar_size + 1px),
                                             $base_color ($nautilus_sidebar_size + 1px),
                                             $base_color 100%);
}

@if $nautilus_style == 'default' or $nautilus_style == 'glassy' {
  $dialog_header_image: linear-gradient(90deg, $dialog_bg_color 5%,
                                               $dark_header_bg 40%);

  $dialog_header_borders_image: linear-gradient(90deg, $dialog_bg_color 0px,
                                                       $header_border 25%);

  $nautilus_actionbar_image: linear-gradient(90deg, rgba($dark_header_bg, 0) 5%,
                                                    transparentize($dark_header_bg, 0.2) 40%);

  $nautilus_actionbar_borders_image: linear-gradient(90deg, rgba($header_border, 0) 0px,
                                                            $header_border 25%);
}

@if $nautilus_style == 'default' or $nautilus_style == 'stable' {
  $nautilus_header_borders_image: linear-gradient(90deg, rgba($header_border, 0) $nautilus_sidebar_size,
                                                         $header_border $nautilus_sidebar_size);
}

@if $nautilus_style == 'stable' or $nautilus_style == 'default' {
  @if $nautilus_version == 'new' {
    $nautilus_header_image: linear-gradient(90deg, rgba($dark_header_bg, 0) $nautilus_sidebar_size,
                                                   $nautilus_borders_color $nautilus_sidebar_size,
                                                   $nautilus_borders_color ($nautilus_sidebar_size + 1px),
                                                   $dark_header_bg ($nautilus_sidebar_size + 1px));
  } @else {
    $nautilus_header_image: linear-gradient(90deg, $dark_sidebar_bg $nautilus_sidebar_size,
                                                   $nautilus_borders_color $nautilus_sidebar_size,
                                                   $nautilus_borders_color ($nautilus_sidebar_size + 1px),
                                                   $dark_header_bg ($nautilus_sidebar_size + 1px));
  }
}

@else if $nautilus_style == 'glassy' {
  @if $nautilus_version == 'new' {
    $nautilus_bg_image: image(rgba($dark_sidebar_bg, 0));
  }

  $nautilus_header_image: linear-gradient(90deg, $dark_sidebar_bg ($nautilus_sidebar_size/2),
                                                 $dark_header_bg 40%);

  $nautilus_header_borders_image: linear-gradient(90deg, rgba($header_border, 0) (($nautilus_sidebar_size/2) - 40px),
                                                         $header_border 40%);
}

//
// Nautilus
//
.nautilus-window {
  &.background.csd {
    background-color: transparent;
    background-image: $nautilus_bg_image;
    border-radius: $background_radius_style;

    > headerbar.titlebar,
    > deck > box > headerbar.titlebar {
      background-color: transparent;
      box-shadow: inset 0 1px rgba(white, 0.1);
      background-image: $nautilus_header_image;
      border: none;
      background-clip: padding-box;
      border-bottom-width: 0;
      border-image: $nautilus_header_borders_image 0 0 1 / 0px 0px 1px stretch;

      @if $nautilus_style == 'stable' and $trans == 'false' {
        > box.left.horizontal {
          background-image: linear-gradient(0deg, $dark_sidebar_bg 0%, $dark_sidebar_bg 95%, transparent 95%, transparent 100%);
        }
      }

      @if $nautilus_style == 'default' or $nautilus_style == 'stable' {
        > .linked.raised > button:first-child { margin-left: $nautilus_sidebar_size - 80px; }
      }

      > .linked > button.disclosure-button { margin-left: $container_padding / 2; }

      > box.horizontal:first-child { // move the search button to right side
        margin-right: -74px;

        entry.search { margin-left: $container_padding; }
      }
    }

    placessidebar.sidebar {
      background-color: transparent;
      min-width: $nautilus_sidebar_size;
      border: none;
      border-bottom-left-radius: $wm_radius;

      @if $nautilus_style == 'stable' {
        background-image: if($trans == 'true', none, $nautilus_sidebar_image);
      }

      @else {
        &.frame { border-right: 1px solid $nautilus_borders_color; }
      }

      @if $nautilus_style == 'glassy' {
        background-image: $nautilus_sidebar_image;
      }

      list { margin-bottom: 6px; }

      row.sidebar-row {
        color: $dark_sidebar_fg;
        background-color: transparent;
        transition: background-image 0;

        .sidebar-icon { color: if($variant == 'light', $selected_bg_color, lighten($selected_bg_color, 20%)); }

        &.has-open-popup,
        &:disabled {
          &, label, image { color: transparentize($dark_sidebar_fg, 0.6); }
        }

        &:backdrop { opacity: 0.85; }

        // row style
        @if $nautilus_style == 'stable' {
          margin: 0 0;

          &:hover {
            transition: background-image 0;
            background-repeat: no-repeat;
            background-color: transparent;
            background-position: left center;
            background-size: $nautilus_sidebar_size 28px;
            background-image: -gtk-scaled(url("assets/sidebar-view-hover-#{$nautilus_sidebar_size}#{$asset_suffix}.png"),
                                          url("assets/sidebar-view-hover-#{$nautilus_sidebar_size}#{$asset_suffix}@2.png"));
          }

          &:active, &:active:hover {
            transition: background-image ease-out 200ms;
            background-repeat: no-repeat;
            background-color: transparent;
            background-position: left center;
            background-size: $nautilus_sidebar_size 28px;
            background-image: -gtk-scaled(url("assets/sidebar-view-active-#{$nautilus_sidebar_size}#{$asset_suffix}.png"),
                                          url("assets/sidebar-view-active-#{$nautilus_sidebar_size}#{$asset_suffix}@2.png"));
          }

          &:selected.has-open-popup,
          &:selected, &:selected:hover {
            color: $fg_color;
            transition: background-image ease-out 200ms;
            background-repeat: no-repeat;
            background-position: left center;
            background-size: $nautilus_sidebar_size 28px;
            background-color: transparent;
            background-image: -gtk-scaled(url("assets/sidebar-view-checked-#{$nautilus_sidebar_size}#{$asset_suffix}.png"),
                                          url("assets/sidebar-view-checked-#{$nautilus_sidebar_size}#{$asset_suffix}@2.png"));

            &, label { color: $fg_color; }
          }
        }

        @else {
          border-radius: $bt_radius;
          margin: 0 6px;
          padding: 2px 4px;

          &:hover {
            background-color: rgba($fg_color, 0.1);
          }

          &:active, &:active:hover {
            transition: background-color ease-out 200ms;
            background-color: rgba($fg_color, 0.2);
          }

          &:selected.has-open-popup,
          &:selected, &:selected:hover {
            color: $fg_color;
            transition: background-color ease-out 200ms;
            background-color: rgba($fg_color, 0.15);

            &, label { color: $fg_color; }
          }
        }

        // other
        &.sidebar-new-bookmark-row {
          color: $selected_bg_color;

          .sidebar-icon { color: inherit; }
        }

        &:drop(active):not(:disabled) {
          &, label, .sidebar-icon { color: $dark_sidebar_fg; }

          &:selected {
            &, label, .sidebar-icon { color: $dark_sidebar_fg; }
            background-color: $drop_target_color;
          }
        }
      }

      separator { background-color: transparent; }

      scrollbar {
        background: none;
        border: none;

        &.overlay-indicator:not(.dragging):not(.hovering) slider {
          background-color: rgba(lighten($dark_sidebar_fg, 15%), 0.35);
          border: none;
        }

        slider {
          min-width: 4px;
          background-color: transparentize(lighten($dark_sidebar_fg, 15%), 0.3);

          &:hover { background-color: lighten($dark_sidebar_fg, 20%); }

          &:hover:active { background-color: $header_button_checked_bg; }

          &:disabled {
            background-color: transparent;
          }
        }

        trough {
          background-color: transparent;
        }
      }
    }

    placesview {
      row.activatable {
        border-radius: $bt_radius;
        margin-right: 6px;
      }

      actionbar.background {
        background-color: $menu_bg;
        margin: 6px;
        border-radius: $wm_radius - 6px;
        box-shadow: $shadow_5, inset 0 1px $highlight_color;
        border: none;
      }
    }
  }

  headerbar {
    min-height: $nautilus_headerbar_size;

    .path-bar-box {
      color: transparent;
      background: none;
      padding: 0 12px;

      .linked.nautilus-path-bar { // for ≥ 3.31.90
        > button:not(:only-child):last-child {
          @include button(header-checked);
        }
      }

      // workaround for 3.30.1
      &.background.frame {
        border: none;
        background-color: transparent;
      }
    }
  }

  notebook {
    margin-left: -1px;
    margin-right: -1px;

    &.background.csd { background-color: transparent; }

    tab { margin-left: -1px; }

    scrolledwindow {
      .view:not(:hover):not(:active):not(:selected) {
        background-color: transparent;
      }
    }

    &, > stack {
      border-radius: 0 0 $nautilus_radius $nautilus_radius;
    }

    > stack {
      background-color: $base_color;
    }

    > stack:not(:only-child) {
      searchbar { background-color: transparent; }
    }

    infobar {
      margin: 6px 10px 10px 6px;
      border-radius: $wm_radius;
      box-shadow: $shadow_5;
      // padding: 0 6px;
    }
  }

  // Floating Bar
  .floating-bar {
    padding: 2px;
    background-color: $selected_bg_color;
    color: $selected_fg_color;
    border-radius: $wm_radius - 6px;
    margin: 6px;
    box-shadow: $shadow_5;

    button {
      border: none;
      border-radius: 100px;
      min-height: 0;
      min-width: 0;
      padding: 0;
      margin-right: 6px;
      -gtk-icon-shadow: none;
      @extend %selected-button;
    }
  }

  // Reset maximized nautilus-window border-radius
  &.maximized, &.tiled, &.fullscreen {
    &.background.csd { border-radius: $maximized_radius_style; }
    notebook { &, > stack { border-radius: 0 0 $maximized_radius $maximized_radius; } }
    headerbar.titlebar { &, &.windowhandle { border-radius: $maximized_radius $maximized_radius 0 0; } }
    placessidebar { border-bottom-left-radius: $maximized_radius; }
  }

  > grid.horizontal > paned.horizontal > separator,
  > deck > box.vertical > paned.horizontal > separator { // Use paned separator to hide stack border-bottom-left-radius
    border: none;
    min-width: 2px;
    min-height: 2px;
    background-color: $base_color;
    background-image: image($base_color);
    background-size: $wm_radius $wm_radius;
    background-position: bottom left;
    background-repeat: no-repeat;

    &:dir(ltr) { margin-left: -1px; }
    &:dir(rtl) { margin-right: -1px; }

    @if $nautilus_style == 'stable' {
      &:dir(ltr) { margin-left: 2px; }
      &:dir(rtl) { margin-right: 2px; }

      &:hover {
        background-image: image($solid_borders_color);
        background-size: 2px 100px;
        background-position: center center;
        background-repeat: no-repeat;
      }
    }
  }
}

preferencesgroup { // gnome 40.0 preferences window
  list {
    @extend %circular_list;

    row.activatable { @extend %circular_row; }

    list {
      margin: 0 0;
      padding: 0 0;
      box-shadow: none;
      background: none;
      border: none;
    }
  }
}

.nautilus-canvas-item { border-radius: 5px; }

// .view.nautilus-desktop,
%nautilus-desktop-canvas-item,
.nautilus-desktop.nautilus-canvas-item {
  color: white;
  text-shadow: 1px 1px transparentize(black, 0.4);

  &:active {
    color: white;
  }

  &:selected {
    color: $selected_fg_color;
    text-shadow: none;
  }
}

.nautilus-canvas-item.dim-label,
.nautilus-list-dim-label {
  color: mix($fg_color, $bg_color, 50%);

  &:selected,
  &:selected:focus {
    color: mix($selected_fg_color, $selected_bg_color, 80%);
  }
}

.nautilus-list-view {
  background-color: $base_color;
  border-radius: 0 0 $wm_radius $wm_radius;

  treeview.view:not(:hover):not(:active):not(:selected) {
    background-color: transparent;
    border-radius: 0;
    // @extend %view;
  }
}

button.nautilus-circular-button.image-button {
  @extend %circular_button;
}

$disk_space_unknown: transparentize($fg_color, 0.5);
$disk_space_used: transparentize($selected_bg_color, 0.2);
$disk_space_free: darken($bg_color, 3%);

.disk-space-display {
  border-style: solid;
  border-width: 1px;

  &.unknown {
    background-color: $disk_space_unknown;
    border-color: darken($disk_space_unknown, 10%);
  }

  &.used {
    background-color: $disk_space_used;
    border-color: darken($disk_space_used, 10%);
  }

  &.free {
    background-color: $disk_space_free;
    border-color: darken($disk_space_free, 10%);
  }
}

@keyframes needs_attention_keyframes {
  0% {
    @include button(header-hover);
  }

  100% {
    @include button(header-active)
  }
}

.nautilus-operations-button-needs-attention {
  animation: needs_attention_keyframes 2s ease-in-out;
}

.nautilus-operations-button-needs-attention-multiple {
  animation: needs_attention_keyframes 3s ease-in-out;
  animation-iteration-count: 3;
}

// Batch renaming dialog
.conflict-row.activatable {
  &, &:active {
    color: $light_fg_color;
    background-color: $error_color;
  }

  &:hover {
    background-color: lighten($error_color, 10%);
  }

  &:selected {
    color: $selected_fg_color;
    background-color: $selected_bg_color;
  }
}

//
// Nemo
//
.nemo-desktop.nemo-canvas-item {
  @extend %nautilus-desktop-canvas-item;
}

.nemo-window {
  .nemo-places-sidebar {
    &.frame { border-width: 0; }

    .places-treeview {
      // -NemoPlacesTreeView-disk-full-bg-color: $dark_solid_borders_color;
      // -NemoPlacesTreeView-disk-full-fg-color: lighten($progress_color, 5%);
    }
  }

  .sidebar {
    color: $dark_sidebar_fg;
    background-color: $dark_sidebar_bg;

    scrolledwindow.frame { border: none; } // Removed treeview double borders

    .view, row {
      background-color: transparent;
      color: $dark_sidebar_fg;
      @extend %row_activatable;

      &.cell:selected {
        color: $fg_color;
        background-color: $sidebar_theme_color;
      }

      &.expander {
        color: mix($dark_sidebar_fg, $dark_sidebar_bg, 50%);

        &:hover { color: $dark_sidebar_fg; }
      }
    }
  }

  paned > separator { background-image: image($solid_borders_color); }

  notebook {
    background-color: $base_color;
  }

  // Rename entry
  .nemo-window-pane {
    widget.entry {
      border: 2px solid if($variant =='light', $entry_highlight, $selected_bg_color);
      background-color: $entry_bg;
      border-radius: $bt_radius;
      box-shadow: none;

      &:selected {
        @extend %selected_items;

        &:focus { @extend %selected_items; }
      }
    }

    treeview.view {
      &, &:selected {
        entry {
          color: $fg_color;
          background-color: $base_color;
          border-radius: $bt_radius;
        }
      }
    }
  }

  .toolbar {
    > button {
      margin-top: 2px;
      margin-bottom: 2px;
      @extend %flat_button;
    }
  }

  .primary-toolbar {
    padding-top: 0;
    padding-bottom: 0;
    border: none;
    color: $header_fg;
    box-shadow: inset 0 -1px $borders_color;
    background-color: $header_bg;

    button {
      @extend %headerbar_buttons;
      padding-top: 0;
      padding-bottom: 0;
      margin: 6px 1px;
    }

    entry {
      @extend %headerbar_entrys;
      margin-top: 4px;
      margin-bottom: 4px;
      margin-left: 0;
      margin-right: 0;
      padding: 2px 10px;
    }

    .linked.raised > button {
      border-radius: $bt_radius;
    }

    // Pathbar
    .linked.path-bar {
      > button, > button.image-button {
        min-height: 0;
        min-width: 0;
        padding-top: 0;
        padding-bottom: 0;
        border-radius: $bt_radius;
      }
    }
  }

  // Floating Bar
  .floating-bar {
    padding: 2px;
    background-color: $selected_bg_color;
    color: $selected_fg_color;
    border-radius: 0;
    border: none;

    &.bottom.left {
      border-top-right-radius: $bt_radius;
    }

    &.bottom.right {
      border-top-left-radius: $bt_radius;
    }

    button {
      border: none;
      border-radius: 3px;
      min-height: 16px;
      min-width: 16px;
      -gtk-icon-shadow: none;
      @extend %undecorated_button;
      @extend %selected-button;
    }
  }
}

// Cinnamon setting
.view.cs-category-view { border-bottom-right-radius: $wm_radius; }


//
// Gedit
//
window.org-gnome-gedit {
  > paned.titlebar {
    > headerbar {
      button.flat.toggle.popup:not(.image-button) { // left-pane header button
        @extend %headerbar_buttons;

        box > .title {
          padding: 0; // remove lateral padding
          margin: -2px 0;
        }
      }
    }

    > separator { @extend %side_separator; }
  }

  > overlay > box.vertical {
    > paned.gedit-side-panel-paned {
      > separator { @extend %side_separator; }

      // 'file-browser' pane
      > box.vertical > stack > grid.horizontal {
        > box.horizontal {  // header-part
          margin: 4px 0;
        }

        > scrolledwindow { // raised widget
          border-bottom-left-radius: $wm_radius;

          treeview.view:not(:hover):not(:selected) {
            background: none;
          }
        }
      }

      // 'files' pane
      stack {
        scrolledwindow {
          viewport.frame {
            list.gedit-document-panel {
              background: none;
            }
          }
        }
      }
    }
  }

  .open-document-selector-treeview.view {
    padding: 3px 6px 3px 6px;
    border-color: $base_color; // disable borders, making them transparent doesn't work for some reason
    &:hover {
      background-color: mix($fg_color, $base_color, 7%);

      &:selected {
        color: $selected_fg_color;
        background-color: $selected_bg_color;
      }
    }
  }

  .open-document-selector-name-label { color: $fg_color; }

  .open-document-selector-path-label {
    color: mix($fg_color, $base_color, 50%);
    font-size: smaller;

    &:selected {
      color: transparentize($selected_fg_color, 0.1);
    }
  }

  .gedit-document-panel { // 'documents' pane

    row.activatable { padding: 6px 0; }

    row button { // 'close' button
      min-width: 22px;
      min-height: 22px;
      padding: 0;
      margin: 0 6px;
      border-radius: 100px;
      // -gtk-outline-radius: 100px;

      image {
        color: inherit;
      }
    }

    row:hover:not(:selected) button {
      color: mix($bg_color, $fg_color, 35%);

      &:hover {
        color: lighten(red, 15%);
      }
      &:active {
        color: $fg_color;
      }
    }

    row:hover:selected button:hover {
      color: lighten(red, 20%);

      &:active {
        color: $selected_fg_color;
      }
    }
  }

  .gedit-document-panel-dragged-row {
    border: 1px solid $borders_color;
    background-color: darken($bg_color, 10%);
    color: $fg_color;
  }

  .gedit-side-panel-paned statusbar {
    border-top: 1px solid $borders_color;
    background-color: $bg_color;
    border-radius: 0 0 $wm_radius $wm_radius;

    frame > border { border: none; }
  }

  .gedit-search-slider {
    background-color: lighten($bg_color, 2%);
    padding: 6px;
    border-color: $borders_color;
    border-radius: 0 0 $bt_radius $bt_radius;
    border-width: 0 1px 1px 1px;
    border-style: solid;
  }

  .gedit-search-entry-occurrences-tag {
    color: transparentize($fg_color, 0.4);
    border: none;
    margin: 2px;
    padding: 2px;
  }

  .gedit-map-frame {
    border {
      @if $variant=='light' {
        border-color: transparentize(black, 0.7);
      }
      border-width: 0;

      &:dir(ltr) {
        border-left-width: 1px;
      }
      &:dir(rtl) {
        border-right-width: 1px;
      }
    }
  }

  &.tiled,
  &.maximized,
  &.fullscreen {
    > overlay > box.vertical {
      > paned.gedit-side-panel-paned {
        > box.vertical > stack > grid.horizontal {
          > scrolledwindow { // raised widget
            border-bottom-left-radius: $maximized_radius;
          }
        }
      }
    }

    &.background.csd,
    .gedit-side-panel-paned statusbar {
      border-radius: 0 0 $maximized_radius $maximized_radius;
    }
  }
}

//
// Pluma
//
.pluma-window statusbar frame > border {
    border: none;
}

.pluma-window notebook > stack scrolledwindow {
    border-width: 0 0 1px 0;
}

#pluma-status-combo-button {
    min-height: 0;
    padding: 0;

    border-top: none;
    border-bottom: none;
    border-radius: 0;
}

//
// Gnome Builder
//
// TODO: Merge this with the upstream stylesheet
.gb-search-entry-occurrences-tag {
  background: none;
}

editortweak .linked > entry.search:focus + .gb-linked-scroller {
  border-top-color: $selected_bg_color;
}

layouttab {
  background-color: $base_color;
}

layout {
  border: 1px solid $borders_color;
}

eggsearchbar box.search-bar {
  border-bottom: 1px solid $borders_color;
}

pillbox {
  color: $selected_fg_color;
  background-color: $selected_bg_color;
  border-radius: 3px;

  &:disabled label {
    color: transparentize($selected_fg_color, 0.5)
  }
}

docktabstrip {
  padding: 0 6px;

  background-color: $bg_color;
  border-bottom: 1px solid $borders_color;

  docktab {
    min-height: 28px;
    border: solid transparent;
    border-width: 0 1px;

    label {
      opacity: 0.5;
    }

    &:checked,
    &:hover {
      label {
        opacity: 1;
      }
    }

    &:checked {
      border-color: $borders_color;
      background-color: $base_color;
    }
  }
}

dockbin {
  border: 1px solid $borders_color;
}

dockpaned {
  border: 1px solid $borders_color;
}

dockoverlayedge {
  background-color: $bg_color;

  docktabstrip {
    padding: 0;
    border: none;
  }

  &.left-edge tab:checked,
  &.right-edge tab:checked {
    border-width: 1px 0;
  }
}

popover.messagepopover {
  &.background {
    padding: 0;
  }

  .popover-content-area {
    margin: 16px;
  }
  .popover-action-area {
    margin: 8px;

    button:not(:first-child):not(:last-child) {
      margin: 0 4px;
    }
  }
}

popover.popover-selector {
  padding: 0;

  list {
    row {
      padding: 5px 0;
    }

    row image {
      margin-left: 3px;
      margin-right: 10px;
    }
  }
}

preferences stacksidebar.sidebar {
  list {
    background-image: _solid($base_color);
  }

  list separator {
    background-color: transparent;
  }
}

devhelppanel entry:focus,
symboltreepanel entry:focus {
  border-color: $borders_color
}

button.run-arrow-button {
  min-width: 12px;
}

omnibar.linked > entry:not(:only-child) {
  margin-left: 1px;
  margin-right: 1px;
  @include entry(header-normal);
  border-left: none;

  &:backdrop {
    @include entry(header-normal);
    // background-image: none;

    opacity: 0.65;
  }
}

entry.search.preferences-search { // preferences-search
  box-shadow: none;
  border: none;
  border-right: 1px solid $borders_color;
  border-bottom: 1px solid $borders_color;
  border-radius: 0;

  &:focus {
    box-shadow: none;
    border-bottom: 1px solid $selected_bg_color;
  }
}

preferencesbin {
  spinbutton {
    border-radius: $bt_radius;
    border: 1px solid $borders_color;
    background-color: $bg_color;

    &:focus { border-color: $selected_bg_color; }

    entry,
    entry:focus { border: none; box-shadow: none; }

    button {
      border-width: 0 0 0 1px;

      // &:first-child {
      //   border-left: 1px solid $borders_color;
      // }
    }
  }

  entry.search { margin: 2px; }
}

dzlpreferencesview stacksidebar.sidebar {
  border-bottom-left-radius: $wm_radius;

  > scrolledwindow > viewport.frame > list {
    border-bottom-left-radius: $wm_radius;
  }
}

dzldockbin#buildui.buildui list.sidebar {
  border-bottom-left-radius: $wm_radius;
}

dzldockbin#editor > ideeditorsidebar.left.pinned.dzldockbinedge {
  border-bottom-left-radius: $wm_radius;

  > dzldockpaned {
    treeview.view.project-tree.i-wanna-be-list-box:not(:hover):not(:selected) {
      background: none;
    }
  }
}

ideeditorutilities.bottom.pinned.dzldockbinedge {
  border-bottom-right-radius: $wm_radius;
}

gstyleslidein {
  #scale_box,
  #strings_controls,
  #palette_controls,
  #components_controls {
    button.toggle:checked {
      color: $fg_color;
    }
  }
}

configurationview {
  entry.flat {
    background: none;
  }

  list {
    border-width: 0;
  }
}

dzldockbin actionbar {
  border-radius: 0 0 $wm_radius $wm_radius;
}

workbench.csd > stack.titlebar:not(headerbar) {
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;

  headerbar {
    &,
    &:first-child,
    &:last-child {
      border-radius: $wm_radius $wm_radius 0 0;
    }
  }
}

window.org-gnome-Builder.workspace {
  > stack#titlebar_container.titlebar {
    > headerbar > omnibar {
      > .linked > entry {
        min-height: 0;

        > overlay > box.horizontal > box.vertical.pan {
          > button {
            min-height: 0;
          }
        }
      }
    }
  }

  > popover.dzlmenubutton {
    > box.vertical > dzlmenubuttonsection.vertical {
      > box.vertical > button.dzlmenubuttonitem {
        color: $alt_fg_color;

        &:active, &:checked {
          color: $fg_color;
          background-color: rgba($fg_color, 0.25);
        }

        > box.horizontal > box.horizontal {
          > label.title {
            color: $fg_color;
          }
        }
      }
    }
  }
}


//
//  Gnome-Logs
//
window.background > box.vertical box.horizontal {
  list.categories { border-radius: 0 0 0 $wm_radius; } // side-pane
    > box.vertical > scrolledwindow > viewport.frame > list {
      row.event.activatable { // > 3.25.90
        color: $fg_color;
        transition-duration: 0.1s;
        &:hover, &:active { color: $fg_color; }

        label.compressed-entries-label {
          // hard-coded background-color?
          background-image: image($suggested_color);
          color: $selected_fg_color;
          font-weight: 700;
        }

        &.compressed-row {
          background-image: image(darken($bg_color, 3%));
          color: darken($fg_color, 20%);
          transition-property: opacity, // exclude background-color
          border-image,
          background-image,
          box-shadow;
          &:hover {
            background-image: image(mix($fg_color, $bg_color, 5%));
            color: $fg_color;
          }
          &:active {
            &, &:focus {
              background-image: image(mix($fg_color, $bg_color, 10%));
              color: $fg_color;
              animation: none;
            }
          }

          &.popover-activated-row {
            background-image: image($selected_bg_color);
            color: $selected_fg_color;
          }

          &-header {
            background-image: image($base_color); // stop highlighting
            color: $selected_bg_color;
            &:hover {
              background-image: image(mix($selected_bg_color, $base_color, 5%));
            }
            &:active {
              &, &:focus {
                background-image: image(mix($selected_bg_color, $base_color, 10%));
                color: $selected_bg_color;
                animation: none;
                }
              }

              label.compressed-entries-label {
                background-image: image($selected_bg_color);
                color: $selected_fg_color;
                transition-duration: 0s;
              }
           }
        }
     }
  }
}

//
// Gnome-Usage
//

// FIXME: why was 'adwaita.css' used for all user-themes? :/
widget {
  &#PROCESSOR,
  &#MEMORY {
    list {
      row {
        margin: -1px; // kill ugly parent borders
        border: 1px solid $solid_borders_color;

        &.max {
          color: $osd_bg_color; // enforce dark foreground
          // FIXME: we can't override the salmon-pinky background
          // background-image: image($destructive_color);
          // border: 1px solid $destructive_color;
        }
      }

      // kill ugly separators
      separator.list {
        box-shadow: inset 0 0 0 1px $solid_borders_color;
      }
    }
  }

  &#STORAGE {
    list {
      margin: -1px; // kill ugly borders

      row.activatable {
        color: rgba($fg_color, 0.75);
        &:hover,
        &:active { color: rgba($fg_color, 0.75); }
      }

      // kill ugly separators
      separator.list {
        box-shadow: inset 0 0 0 1px $solid_borders_color;
      }
    }
  }

  &#PERFORMANCE {
    searchbar {
      box-shadow: inset 0 -2px $borders_color, inset 0 -1px $bg_color;  // Removed double borders under headerbar
      entry, button { margin-bottom: 2px; }
    }

    .sidebar {
      background-color: $base_color;
      border-bottom-left-radius: $wm_radius;
    }
  }
}

graph-switcher-button.toggle {
  color: rgba($fg_color, 0.75);
  font-weight: 500;
  &:hover { // use opaque
    color: $fg_color;
    background-image: image(if($variant == 'light', rgba(black, 0.05), rgba(white, 0.03)));
  }
}

rg-graph.big {
  // FIXME: We need to re-define these properties to prevent weird
  // 'non-repeated' imaging behind the main graph.
  background-position: left top;
  background-origin: border-box;
  background-repeat: repeat;
}

box.speedometer {
  // FIXME: 'outter' meant 'outer'?
  // circular progress should be drawn with our $accent_color though,
  // damned adwaita.css picks @theme_selected_bg_color up.
  &-outter { opacity: 0.8; } // reduce alpha for our troughs

  &-content-area { // cover up meter troughs with selection colour
    box-shadow: 0 0 0 4px rgba($selected_bg_color, 0.2);
  }
}

//
// Gnome Documents
//

.documents-scrolledwin.frame {
  border-width: 0;
}

button.documents-load-more {
  border-width: 1px 0 0;
  border-radius: 0;
}

.documents-icon-bg {
  background-color: $selected_bg_color;
  color: $selected_fg_color;
  border-radius: 2px;
}

%documents-collection-icon,
.documents-collection-icon {
  background-color: transparentize($fg_color, 0.7);
  border-radius: 2px;
}

button.documents-favorite:active,
button.documents-favorite:active:hover {
  color: lighten($selected_bg_color, 20%);
}

%documents-entry-tag,
.documents-entry-tag {
  color: $selected_fg_color;
  background: $selected_bg_color;
  border-radius: 3px;
  border-width: 0;
  margin: 2px;
  padding: 4px;

  &:hover {
    color: $selected_fg_color;
    background: lighten($selected_bg_color, 4%);
  }
  &:active {
    color: $selected_fg_color;
    background: darken($selected_bg_color, 4%);
  }
  &.button {
    box-shadow: none;
    border: none;
    background-color: transparent;
  }
}

.content-view.document-page {
  border-style: solid;
  border-width: 3px 3px 6px 4px;
  border-image: url("assets/thumbnail-frame.png") 3 3 6 4;
}

//
// Gnome Photos
//
.photos-entry-tag {
  @extend %documents-entry-tag;
}

.photos-collection-icon {
  @extend %documents-collection-icon;
}

.photos-fade-in {
  opacity: 1.0;
  transition: opacity 0.2s ease-out;
}

.photos-fade-out {
  opacity: 0.0;
  transition: opacity 0.2s ease-out;
}

//
// Gnome Tweak Tool ( Gnome tweaks )
//

hdyleaflet, leaflet, box.horizontal > stack.background {
  frame > border { border: none; }

  frame:not(.view) list:not(.contacts-contact-list) { // Don't set this to Gnome-Contacts
    @extend %circular_list;

    row.activatable {
      @extend %circular_row;

      .row-header > button:not(.text-button) {
        min-height: 28px;
        min-width: 28px;
        padding: 0;
        margin: 4px 0;
      }
    }
  }

  frame.view {
    @extend %circular_list;

    list {
      background: none;

      > separator {
        background: none;
        min-height: 0;
      }

      row.activatable { @extend %circular_row; }
    }
  }

  list.view, list.frame {
    @extend %circular_list;

    row.activatable { @extend %circular_row; }
  }

  > box.vertical > scrolledwindow > viewport.frame {
    &,
    > stack,
    > stack > box.vertical {
      > list > row.activatable { @extend %sidebar_row; }
    }
  }
}

list {
  &.tweak-group {
    list {
      @extend %circular_list;

      row.activatable { @extend %circular_row; }
    }
  }
}

.titlebar > headerbar.titlebar.tweak-titlebar-left,
.titlebar > headerbar.titlebar.tweak-titlebar-right {
  border: none;
}

// Themed side headerbar
.titlebar > headerbar.titlebar.tweak-titlebar-left {
  @extend %side_headerbar_left;
}

.titlebar > headerbar.titlebar.tweak-titlebar-right {
  @extend %side_headerbar_right;
}

row#AutostartTitle.tweak {
  padding: 3px;
  background-color: $base_color;
}

.tweak-group-startup {
  @extend %circular_list;

  row.tweak-startup:not(:hover):not(:selected) {
    background: none;
  }
}

// Themed left sidebar
.tweak-category:not(:selected):not(:hover) {
  background: none;
}

// sidebar on gnome tweak
.tweak-categories {
  background-image: none;
  background-color: rgba($dark_sidebar_bg, 1);
  border-radius: 0 0 0 $wm_radius;

  .maximized &,
  .fullscreen &,
  .tiled &,
  .tiled-top &,
  .tiled-right &,
  .tiled-bottom &,
  .tiled-left & { border-radius: 0 0 0 $maximized_radius; }

  > separator {
    min-width: 0;
    min-height: 0;
    background: none;
  }
}

// separator of sidebar on Gnome control center and Gnome tweaks
window.background.csd {
  > hdyleaflet, > leaflet, > box.horizontal {
    > separator.vertical {
      @extend %side_separator;
    }

    > box.vertical {
      > searchbar {
        @extend %side_searchbar;
      }
    }
  }

  > hdyleaflet > box.vertical > stack.main-container,
  > leaflet > box.vertical > stack.main-container { // Right side
    background-color: $base_color;
    border-bottom-right-radius: $wm_radius;
  }

  &.maximized, &.tiled, &.fullscreen {
    > hdyleaflet > box.vertical > stack.main-container {
      border-bottom-right-radius: $maximized_radius;
    }

    // sidebar on gnome tweak
    .tweak-categories {
      border-radius: 0 0 0 $maximized_radius;
    }
  }
}

//
//  Gnome Control Center
//
window.background.csd {
  > box.titlebar.horizontal {
    > headerbar:first-child {
      @extend %side_headerbar_left;
    }

    > headerbar:last-child {
      @extend %side_headerbar_right;
    }
  }

  > headerbar.titlebar { // gnome 3.32 or later
    > box.horizontal > headerbar:first-child,
    > hdyleaflet > headerbar:first-child,
    > leaflet > headerbar:first-child {
      @extend %side_headerbar_left;
    }

    > box.horizontal > headerbar:last-child,
    > hdyleaflet > headerbar:last-child,
    > leaflet > headerbar:last-child {
      @extend %side_headerbar_right;
    }

    > box.horizontal > separator.sidebar,
    > hdyleaflet > separator.sidebar,
    > leaflet > separator.sidebar {
      @extend %side_separator;
    }
  }

  > stack {
    border-radius: 0 0 $wm_radius $wm_radius;
  }

  > box:not(.titlebar).horizontal > separator.vertical {
    @extend %side_separator;
  }

  > leaflet > stack.background, // > 3.38.0
  > hdyleaflet > stack.background, // > 3.34.0
  > box.horizontal > stack.background {
    background-color: $base_color;
    border-bottom-right-radius: $wm_radius;

    > widget {
      > box.horizontal > box.horizontal > box.vertical {
        > button { // wallpaper set button
          &:active {
            color: $fg_color;
            background-image: none;
            background-color: if($variant=='light', darken($button_bg, 15%), lighten($button_bg, 10%));
            border-color: $dark_borders_color;
          }
        }
      }

      > box.vertical > box.vertical { // Gnome 3.34 Wallpaper setting
        > scrolledwindow > viewport.frame {
          background-color: $base_color;
          border-bottom-right-radius: $wm_radius + 1px;

          > box.vertical {
            background: none;
          }
        }
      }
    }
  }

  > leaflet > box.vertical > scrolledwindow.view, // > 3.38.0
  > hdyleaflet > box.vertical > scrolledwindow.view, // > 3.34.0
  > box.horizontal > box.vertical > scrolledwindow.view { // > 3.25.90
    background-color: rgba($dark_sidebar_bg, 1);
    border-bottom-left-radius: $wm_radius + 1px;

    > viewport.frame > stack {
      background-color: transparent;

      list { // left-pane
        background-color: transparent;

        separator { background: none; }

        row.activatable:not(:hover):not(:active):not(:selected) {
          background-color: transparent;
        }
      }
    }
  }

  &.maximized, &.tiled, &.fullscreen {
    > stack {
      border-radius: 0 0 $maximized_radius $maximized_radius;
    }

    > leaflet > stack.background, // > 3.38.0
    > hdyleaflet > stack.background, // > 3.34.0
    > box.horizontal > stack.background {
      border-bottom-right-radius: $maximized_radius;

      > widget {
        > box.vertical > box.vertical { // Gnome 3.34 Wallpaper setting
          > scrolledwindow > viewport.frame {
            border-bottom-right-radius: $maximized_radius;
          }
        }
      }
    }

    > leaflet > box.vertical > scrolledwindow.view, // > 3.38.0
    > hdyleaflet > box.vertical > scrolledwindow.view, // > 3.34.0
    > box.horizontal > box.vertical > scrolledwindow.view { // > 3.25.90
      border-bottom-left-radius: $maximized_radius;
    }
  }
}

box.horizontal > separator.sidebar,
hdyleaflet > separator.sidebar,
leaflet > separator.sidebar,
leaflet > leaflet > separator.sidebar { // reset
  @extend %side_separator;
}

//
//  Gnome system monitor
//
window#gnome-system-monitor.background.csd {
  > box.vertical > stack {
    background-color: $base_color;
    border-radius: 0 0 $wm_radius $wm_radius;

    > box.vertical > scrolledwindow {
      treeview.view:not(:hover):not(:selected):not(.progressbar):not(.trough) {
        background: none;
      }
    }
  }

  &.maximized, &.tiled, &.fullscreen {
    > box.vertical > stack {
      border-radius: 0 0 $maximized_radius $maximized_radius;
    }
  }
}

//
// gnome-sound-recorder
//
stack {
  > grid.vertical {
    > scrolledwindow {
      border: none;
      border-radius: 0 0 $wm_radius $wm_radius;

      > viewport.frame {
        list {
          border-radius: 0 0 $wm_radius $wm_radius;
        }
      }
    }

    scrolledwindow.frame.emptyGrid { border: none; } // Removed ugly borders
  }
}

window.background.csd {
  &.maximized, &.tiled, &.fullscreen {
    stack {
      > grid.vertical {
        > scrolledwindow {
          border-radius: 0 0 $maximized_radius $maximized_radius;

          > viewport.frame {
            list {
              border-radius: 0 0 $maximized_radius $maximized_radius;
            }
          }
        }
      }
    }
  }
}

//
// Gnome Contacts
//
window.background.csd {
  > headerbar.titlebar.selection-mode {
    > hdyleaflet > headerbar,
    > leaflet > headerbar {
      color: $header_fg;

      > button { @extend %headerbar_buttons; }
    }
  }

  > overlay > grid.horizontal {
    > frame:dir(ltr) > border { // Removed ugly borders
      border-top-width: 0;
      border-left-width: 0;
      border-bottom-width: 0;
    }

    > overlay > stack > box.horizontal > grid.horizontal {
      > scrolledwindow.contacts-contact-form {
        border-bottom-right-radius: $wm_radius + 1px;
      }
    }
  }

  > overlay > hdyleaflet,
  > overlay > leaflet {
    > stack > frame > grid.vertical {
      background-color: rgba($dark_sidebar_bg, 1);
      border-bottom-left-radius: $wm_radius;

      // list.contacts-contact-list {}
    }

    > separator.sidebar {
      @extend %side_separator;
    }

    > overlay > scrolledwindow > viewport.frame {
      background-color: rgba($base_color, 1);
      border-bottom-right-radius: $wm_radius;

      > hdycolumn > stack > box.horizontal > box.vertical > box.horizontal {
        > button.image-button {
          @extend %circular_button;
          padding: 2px;
        }
      }
    }
  }

  &.maximized, &.tiled, &.fullscreen {
    > overlay > hdyleaflet,
    > overlay > leaflet {
      > stack > frame > grid.vertical {
        border-bottom-left-radius: $maximized_radius;
      }

      > overlay > scrolledwindow > viewport.frame {
        border-bottom-right-radius: $maximized_radius;
      }
    }
  }
}

entry.contacts-postal-entry {
  // background-color: transparent;
  @extend %Linked_entrys;

  &:focus {
    @if $variant == 'dark' { box-shadow: inset 0 0 0 1px $entry_highlight; }
    @if $variant == 'light' { box-shadow: 0 1px 1px 0 transparent, inset 0 0 0 1px $entry_highlight; }
  }
}

entry.contacts-postal-entry:focus + entry.contacts-postal-entry { border-top-color: $entry_highlight; }

//
// Gnome Web
//
stack#titlebar_container.titlebar {
  > stack > headerbar,
  > headerbar.titlebar > deck > headerbar { // Gnome 3.38
    border-color: $header_bg;

    // entry.suggestion.url_entry {}
  }
}

notebook.main-notebook {
  > header.top {
    margin-top: 0;

    > tabs > tab {
      &:checked {
        border-top-color: $header_bg;
      }

      &:first-child { //Not use
        border-left-width: 0;
      }
    }
  }

  webkitwebview {
    border-radius: 0 0 $wm_radius $wm_radius;
  }
}

// gnome 40.0
window.background.csd {
  > deck > deck > fullscreenbox > flap > box > windowhandle {
    > headerbar.titlebar { // Gnome 40.0
      border-color: $header_bg;
    }
  }
}

tabbox {
  background-color: darken($header_bg, 10%);
  box-shadow: inset 0 -1px $borders_color;

  > tab {
    @extend %tabs_tab;
    border-top: none;
    padding: 2px 10px;
    min-width: 24px;
    min-height: 24px;
    border-top: 1px solid $borders_color;

    &:checked {
      border-top-color: $header_bg;
    }

    button {
      min-height: 20px;
      min-width: 20px;
      border-radius: 3px;
      border: none;
      padding: 0;
      @extend %flat_button;

      &:hover {
        color: $fg_color;
        background-color: rgba($borders_color, 0.1);
      }

      &:active, &:active:hover {
        color: if($variant == 'light', darken($fg_color, 10%), lighten($fg_color, 10%));
        background-color: rgba($borders_color, 0.2);
      }
    }
  }
}

//
// Gnome Music
//
window.background.csd {
  > box.vertical > overlay > stack.background {
    border-radius: 0 0 $wm_radius $wm_radius;
  }

  &.maximized, &.tiled, &.fullscreen {
    > box.vertical > overlay > stack.background {
      border-radius: 0 0 $maximized_radius $maximized_radius;
    }
  }
}

//
// Gnome Weather
//
#weather-page,
#weekly-forecast-frame {
  border-bottom-right-radius: $wm_radius;

  .maximized &, .tiled &, .fullscreen & {
    border-bottom-right-radius: $maximized_radius;
  }
}

#weather-page-content-view {
  border-bottom-right-radius: $wm_radius;
  border-bottom-left-radius: $wm_radius;

  .maximized &, .tiled &, .fullscreen & {
  border-bottom-left-radius: $maximized_radius;
    border-bottom-right-radius: $maximized_radius;
  }
}

//
// Gnome Clocks
//
window.background.csd.unified {
  border-top-left-radius: $wm_radius;
  border-top-right-radius: $wm_radius;

  > deck > deck > deck {
    > box.vertical > headerbar.titlebar.windowhandle {
      > viewswitchertitle > squeezer {
        > viewswitcher > box.horizontal {
          > button.radio {
            margin: 0;
            border-radius: 0;
          }
        }
      }
    }
  }

  &.maximized, &.tiled, &.fullscreen {
    border-radius: 0 0 $maximized_radius $maximized_radius;
  }
}

hdyviewswitcherbar > actionbar,
viewswitcherbar > actionbar { // Gnome 3.38
  background: none;
  border: none;
}

//
// Gnome Calendar
//

window.background.org-gnome-Calendar {
  .week-view weekgrid {
    event.color-light {
      &, & > stack > grid > label {
        color: rgba(black, 0.75);
      }
    }

    event.color-dark {
      &, & > stack > grid > label {
        color: rgba(white, 1);
      }
    }
  }
}

//
// Polari
//
.polari-room-list {
  .sidebar {
    background-color: $dark_sidebar_bg;
    border-bottom-left-radius: $wm_radius;
  }

  &.maximized, &.tiled, &.fullscreen {
    .sidebar {
      border-bottom-left-radius: $maximized_radius;
    }
  }
}

stack.view.polari-entry-area {
  background-color: $bg_color;
  border-top: 1px solid $borders_color;
  border-bottom-right-radius: $wm_radius;

  button.popup.flat.toggle.polari-nick-button {
    &:hover {
      background-color: rgba($fg_color, 0.15);
      box-shadow: none;
      background-image: none;
    }

    &:active, &:checked {
      background-color: rgba($fg_color, 0.25);
      box-shadow: none;
      background-image: none;
    }
  }

  .maximized &, .tiled &, .fullscreen & {
    border-bottom-right-radius: $maximized_radius;
  }
}

stack:disabled.view.polari-entry-area { background-image: image($bg_color); }

//
// Transmission
//
.tr-workarea undershoot,
.tr-workarea overshoot {
  border-color: transparent; // Remove black border on over- and undershoot
}

//
// Atril (MATE pdf viewer)
//
.atril-window .primary-toolbar toolbar {
  background: none;
}

//
// Gnome Flashback
//
#gf-bubble,
#gf-osd-window,
#gf-input-source-popup,
#gf-candidate-popup {
  &, &.solid {
    color: lighten($osd_fg_color, 7%);
    background-color: $osd_bg_color;
    border: 1px solid darken($osd_bg_color, 8%);
    border-radius: 2px;
  }

  levelbar {
    block {
      &.low, &.high, &.full {
        background-color: $selected_bg_color;
        border-color: $selected_bg_color;
      }

      &.empty { background-color: darken($osd_bg_color, 5%); }
    }

    trough { background: none; }
  } // FIXME still needs button styling
}

#gf-input-source {
  min-height: 32px;
  min-width: 40px;

  &:selected {
    color: $selected_fg_color;
    background-color: $selected_bg_color;
    border-radius: 2px;
  }
}

gf-candidate-box {
  label {
    padding: 3px;
  }

  &:hover,
  &:selected {
    color: $selected_fg_color;
    background-color: $selected_bg_color;
    border-radius: 2px;
  }
}

//
// rhythmbox
//

%toolbar_radio_button {
  @if $variant == 'dark' { border: none; }

  &:active, &:checked {
    background-image: none;
    color: if($variant=='light', $selected_fg_color, $base_color);
    background-color: if($variant=='light', rgba(black, 0.5), darken(white, 25%));
    border-color: $borders_color;
  }
}

// add top-border to inline-toolbar
.sidebar-paned .inline-toolbar.horizontal.sidebar-toolbar {
  box-shadow: inset 0 1px $borders_color;
  padding: 4px;
  background-color: darken($bg_color, 3%);

  button.image-button {
    @extend %toolbar_radio_button;

    > widget > box > image { padding: 0; }
  }
}

// tweak sidebar styling
.sidebar-paned {
  scrolledwindow { border: none; }

  // treeview.view.sidebar { }
}

// tweak border and frame in alt-toolbar
window.csd > box.vertical > box.vertical,
window.solid-csd > box.vertical > box.vertical {
  > toolbar.horizontal {
    margin: -1px 0;
    border-top: 1px solid $borders_color;
    border-bottom: none;
    box-shadow: none;
    background-color: transparent;

    > toolitem > .linked > button,
    > toolitem > box.horizontal > button {
      min-height: 36px;
      min-width: 36px;
      padding: 0;
      margin-top: 8px;
      margin-bottom: 8px;

      @extend %toolbar_radio_button;
    }
  }

  > frame {
    margin: -1px 0;
    padding: 0;

    > border { border: none; }
  }
}

// hard-coded spacing depends on non-scalable unit,
// seems cover-art widget is the most biggest thing?
window.background > box.vertical > toolbar.primary-toolbar {
  > toolitem {
    > .linked > button.image-button.raised { // 'shuffle/repeat'
      min-height: 36px;
      min-width: 36px;
      padding: 0;
      margin: 0;
      @extend %toolbar_radio_button;

      > widget > box > image { padding: 0; }
    }

    button.flat.scale { // 'volume'
      min-height: 24px;
      min-width: 36px;
      padding: 0;
      margin-top: 8px;
      margin-bottom: 8px;
    }

    > box.horizontal:not(.linked) > button.toggle,
    > .linked > button:not(.toggle):not(.raised):not(.flat) {
      min-height: 28px;
      min-width: 28px;
      padding: 0;
      margin: 0;
      @extend %toolbar_radio_button;
    }
  }
}

//
// Gnome Calculator
//
window.background {
  > headerbar.titlebar { // mode-selector button
    > button.flat.popup.toggle.text-button.title {
      // .title class existed
      margin: 6px 0; // set standard margins

      > grid > widget { // down arrow
        padding-top: 3px;
        // add spacing between arrow and label
        &:dir(ltr) { padding-left: 4px; }
        &:dir(rtl) { padding-right: 4px; }
      }
    }
  }

  > grid.vertical > box.vertical > widget,
  > grid.vertical > box.vertical > box.vertical > widget,
  > grid.vertical > box.vertical grid.math-buttons {
    button {
      font-weight: 700;

      &:not(.suggested-action) {
        &:active { @include button(flat-active); border-color: $borders_color; }
        &:checked { @include button(flat-checked); border-color: $borders_color; }
      }

      // &.suggested-action {  // '=' button
      // }
    }
  }
}

//
// Epiphany (Gnome Web)
//

$question_bg_color: #FFEA00;

// incognito-mode styling
//
// most of widget styling are hard-coded by ephy's stylesheet,
// but we should force using dark foregrounds at least...

headerbar.titlebar.incognito-mode {
  entry {
    @include entry(header-normal);

    &:focus { @include entry(header-focus); }
    &:disabled { @include entry(header-insensitive); }
  }
}

// reset inverted foreground colour
notebook > box > stack > box.vertical > paned.vertical > overlay {
  > .floating-bar { color: rgba($fg_color, 0.75); }
}

.background:not(.csd) > box.vertical > headerbar {
  // conflicts with .primary-toolbar styling?
  .linked > button.image-button { // = 'back/forward' button

  }
}

// overrides foregrounds for 3.24's ssd-mode
.background headerbar entry {
  &.starred,
  &.non-starred {
    @include entry(header-normal);

    &:focus { @include entry(header-focus); }
    &:disabled { @include entry(header-insensitive); }
  }

  // render yellow 'star' icon if bookmarked
  &.starred > image.right {
    color: darken($question_bg_color, 10%);
    &:hover,
    &:active,
    &:checked { color: $question_bg_color; }
  }
}

// popover for downloaded lists
popover.background:not(.emoji-picker) > box.vertical {
  // For clean button
  button:not(.destructive-action):not(.suggested-action):only-child {
    &:active, &:checked { @include button(flat-active); }
  }
}

popover.background:not(.emoji-picker) > box.vertical > scrolledwindow {
  // re-define background colours for GtkListBox
  > viewport.frame > list.background {
    background-color: transparent;

    > row.activatable {
      background-color: if($variant=='light', $bg_color, lighten($bg_color, 10%));
      color: rgba($fg_color, 0.85);
      border-radius: $bt_radius;
      border: 1px solid $borders_color;
      margin: 2px;
      @if $variant=='light' { box-shadow: $shadow_3, inset 0 0 0 1px rgba($borders_color, 0.01); }

      &:hover { @include button(hover); }
      &:active, &:checked { @include button(flat-active); }
    }
  }
}

// popover for bookmarks
popover.background:not(.emoji-picker) > box.vertical > stack > box.vertical {

  scrolledwindow > viewport.frame {
    border: 1px solid $borders_color;

    > list.background > row.activatable.bookmarks-row {
      background-color: rgba($base_color, 0.35);
      color: rgba($fg_color, 0.85);
      border-bottom: 1px dashed rgba($borders_color, 0.05);
      padding: 6px;

      &:hover,
      &:active,
      &:checked { color: $fg_color; background-color: rgba($fg_color, 0.05); }

      button.flat {
        min-width: 16px;
        min-height: 16px;
        padding: 4px; // Same as of image.sidebar-icon
        // margin: 0 4px;
        border-radius: 100px;
        // -gtk-outline-radius: 100px;
      }
    }
  }
}

// bookmark-tag flowbox-childs (almost hard-coded)
flowboxchild.bookmark-tag-widget {
  color: $bg_color; // unchecked
  font-weight: 500;

  label { margin-bottom: 2px; }

  &-selected { color: $selected_fg_color; } // checked
}


//
// Fractal
//
.background.csd.main-window {
  .sidebar.rooms-sidebar {
    border-bottom-left-radius: $wm_radius;
  }

  &.maximized, &.tiled, &.fullscreen {
    .sidebar.rooms-sidebar {
      border-bottom-left-radius: $maximized_radius;
    }
  }
}

//
// documents-scrolledwi (Totem, Documents, EvView)
//
.documents-scrolledwin {
  background-color: transparent;

  .content-view:not(:selected):not(:hover) {
    background-color: transparent;
    // border-radius: 0 0 $wm_radius $wm_radius;
  }

  .content-view:hover { background-color: rgba($fg_color, 0.08); }

  viewport.frame { // Documents
    background-color: transparent;

    widget > frame.content-view:not(:selected):not(:hover) {
      border { border: none; }

      background-color: transparent;
      // border-radius: 0 0 $wm_radius $wm_radius;
    }
  }
}

// Documents

window.background.csd { // Documents actionbar
  > box.vertical > overlay > stack > box.vertical {
    > actionbar {
      border-radius: 0 0 $wm_radius $wm_radius;
    }
  }

  &.maximized, &.tiled, &.fullscreen {
    > box.vertical > overlay > stack > box.vertical {
      > actionbar {
        border-radius: 0 0 $maximized_radius $maximized_radius;
      }
    }
  }
}

//
// Document Viewer
//
window.background.csd {
  > box.vertical {
    > scrolledwindow {
      > iconview.view.content-view:not(:hover):not(:selected) {
        background-color: transparent;
        border-radius: $wm_radius;
      }
    }

    > paned.horizontal > box.vertical > scrolledwindow {
      > treeview.view:not(:hover):not(:selected) { background-color: transparent; }
    }
  }

  evview.view.content-view {
    background-color: transparent;
    border-radius: 0 0 $wm_radius $wm_radius;
  }

  &.maximized, &.tiled, &.fullscreen {
    > box.vertical {
      > scrolledwindow {
        > iconview.view.content-view:not(:hover):not(:selected) {
          border-radius: $maximized_radius;
        }
      }
    }

    evview.view.content-view {
      border-radius: 0 0 $maximized_radius $maximized_radius;
    }
  }
}

//
// Archive Manager
//
.background.csd {
  > grid.horizontal > paned.horizontal {
    > scrolledwindow {
      border-radius: 0 0 $wm_radius $wm_radius;
      background-color: $base_color;

      treeview.view:not(:hover):not(:selected) {
        background-color: transparent;
      }
    }

    > box.vertical {
      > scrolledwindow {
        border-radius: 0 0 0 $wm_radius;
        background-color: $bg_color;

        treeview.view:not(:hover):not(:selected) {
          background-color: transparent;
        }
      }
    }
  }

  &.maximized, &.tiled, &.fullscreen {
    > grid.horizontal > paned.horizontal {
      > scrolledwindow {
        border-radius: 0 0 $maximized_radius $maximized_radius;
      }

      > box.vertical {
        > scrolledwindow {
          border-radius: 0 0 0 $maximized_radius;
        }
      }
    }
  }
}

//
// Eye of GNOME Image Viewer
//
.background.csd {
  > box.vertical > box.vertical > box.vertical{
    > paned.horizontal {
      > separator {
        background-image: none;
        background-color: $header_border;
      }
    }
  }
}

//
// Gnome-Disk
//
window.background.csd {
  > box.vertical > paned.horizontal {
    > scrolledwindow {
      treeview.view {
        min-width: 240px;
        @extend %row_activatable;

        &:not(:selected):not(:hover) {
          background-color: transparent;
        }
      }
    }

    > separator {
      background-image: if($variant == 'light', image($solid_borders_color), image($header_border));
    }
  }

  > paned.titlebar {
    background-color: $header_bg;
    box-shadow: inset 0 1px $highlight_color;

    > headerbar {
      background: none;
      box-shadow: none;
    }

    > separator {
      background: none;
    }
  }
}

//
// Extensions
//
window.background.csd {
  > stack, // GameMode setting
  > stack > scrolledwindow > viewport > box, // User Themes (Workspace) setting
  > box > stack > scrolledwindow > viewport > box {
    > list {
      @extend %circular_list;

      row.activatable { @extend %circular_row; }
    }
  }

  stack stack stack frame, // ArcMenu setting
  > stack > stack > box > frame, // Night Theme Switcher setting
  > stack > stack > box > box > frame, // Night Theme Switcher setting bottom lists
  > stack > box > stack > box > frame, // ArcMenu setting
  > stack > box > stack > scrolledwindow > viewport frame, // ArcMenu setting
  > stack > box > stack > box > scrolledwindow > viewport > frame, // ArcMenu setting
  > stack > grid > scrolledwindow > viewport > box > frame { // GSConnect setting
    > border { border: none; }

    > list {
      @extend %circular_list;

      row.activatable { @extend %circular_row; }
    }
  }

  > stack > box > box > list,
  > stack > box > stack > scrolledwindow > viewport > list { // ArcMenu setting sidebar
    border-bottom-left-radius: $wm_radius;
  }

  &.maximized, &.tiled, &.fullscreen {
    > stack > box > box > list,
    > stack > box > stack > scrolledwindow > viewport > list { // ArcMenu setting sidebar
      border-bottom-left-radius: $maximized_radius;
    }
  }
}

//
// Mate OSD Window
//
MsdOsdWindow.background.osd {
  border-radius: 2px;
  border: 1px solid darken($osd_bg_color, 8%);

  .progressbar {
    background-color: $selected_bg_color;
    border: none;
    border-color: red;
    border-radius: 5px;
  }
  .trough {
    background-color: darken($osd_bg_color, 5%);
    border: none;
    border-radius: 5px;
  }
}

//
// Mate/Gnome Flashback Panel
//
.mate-panel-menu-bar,
panel-toplevel.background {
  &, menubar {
    background-color: opacify($panel_bg, 1);
  }

  menubar,
  #PanelApplet label,
  #PanelApplet image {
    color: $panel_fg;
  }

  button:not(#tasklist-button) {  // Panel buttons
    @extend %panel_button;
  }

  button,
  #tasklist-button {
    label, image {
      color: inherit;
    }
  }

  .wnck-pager {
    color: mix($panel_fg, black, 50%);
    background-color: darken($panel_bg, 10%);

    &:hover {
      background-color: lighten($panel_bg, 5%);
    }

    &:selected {
      color: lighten($selected_bg_color, 20%);
      background-color: $selected_bg_color;
    }
  }
}

//
// Caja
//
.caja-desktop {
  @extend %nautilus-desktop-canvas-item;
}

.caja-notebook {
  border-top: 1px solid $borders_color;
}

.caja-side-pane {
  &, text, treeview,
  > notebook > stack > widget > box {
    color: $dark_sidebar_fg;
    caret-color: $dark_sidebar_fg;
    background-color: opacify($dark_sidebar_bg, 1);
  }

  > box button {
    &:not(:active):not(:checked) { color: $dark_sidebar_fg; }
    // &:hover:not(:active) { @include button(hover); }
  }

  .frame { border-color: $borders_color; }

  junction { background-color: darken($dark_sidebar_bg, 5%); }
}

.caja-navigation-window {
  .primary-toolbar {
    background-color: $header_bg;
  }

  .caja-side-pane {
    background-color: transparent;

    .frame {
      border-width: 1px 0 0;
    }
  }

  paned > separator {
    background-image: image($solid_borders_color);
  }
}

.caja-side-pane {
  treeview.view, .view {
    background: none;

    &:hover {
      background-color: rgba($fg_color, 0.1);
    }

    &:active, &:selected {
      background-color: $selected_bg_color;
    }
  }

  textview.view text { background: none; }

  scrollbar {
    background: none;
  }

  // notebook .view > box.vertical {
  //   border-bottom-left-radius: $wm_radius;
  // }
}

.caja-notebook .frame {
  border-width: 0 0 1px;
}

.caja-search-bar {
  entry {
    // margin: 2px 0;

    &:focus {
      box-shadow: none;
    }
  }
}

//
// Xfce4
//
$text_shadow: 0 0 1px rgba(0, 0, 0, 0.26),
              0 1px 2px rgba(0, 0, 0, 0.32),
              0 2px 3px rgba(0, 0, 0, 0.12);

%panel_button {
  color: $panel_fg;
  border-radius: $bt_radius;
  background: none;
  border: none;

  &:hover:not(:active):not(:checked) {
    color: $panel_fg;
    background-color: rgba($panel_fg, 0.2);
  }

  &:checked {
    color: $panel_fg;
    background-color: rgba($panel_fg, 0.25);
    label, image { color: inherit; }
  }

  &:active {
    color: $panel_fg;
    background-color: rgba($panel_fg, 0.3);
  }
}

.xfce4-panel.panel {
  background-color: $panel_bg;
  text-shadow: none;
  -gtk-icon-shadow: none;
  border: none;

  button, button.flat {
    @extend %panel_button;
  }
}

.XfceHeading {
  border: 0 none transparent;
  background-color: $bg_color;
  color: $fg_color;
}

.xfce4-panel {
  background-color: $panel_bg;
  color: $panel_fg;
  font-weight: 700;
  text-shadow: none;
  -gtk-icon-shadow: none;
  box-shadow: none;
  border-width: 0;

  &, // unset borders
  frame > border { border: none; }

  &#XfcePanelWindow { // main panel container >= 4.13.3?
    // FIXME: unneeded 1px borders are reserved by its code itself
    border: none;

    &, &.marching-ants { transition: none; } // unset transitions
  }

  button.flat { @extend %panel_button; }

  button {
    font-weight: 700;
    @extend %panel_button;

    &#launcher-arrow { // launcher applet
      // FIXME: quite weird pseudo-classe transitions, especially :hover
      // state can't be cleared properly ( -> an upstream issue)
      &, + button.toggle {
        &:hover { box-shadow: none; } // hide indicators
      }

      + button.toggle:checked { // 'arrow' toggle button
        color: $selected_bg_color;
        box-shadow: none;
      }
    }

    &#xfce4-notification-plugin {
      padding: 0 1px; // for 4.12.2
    }
  }

  menu {
    font-weight: 400; // for enforcing regular weight
    text-shadow: none;
  }

  menubar.-vala-panel-appmenu-private { // xfce4 appmenu plugin
    > menuitem {
      font-weight: normal;
    }
  }

  widget.tasklist > button.toggle { font-weight: 400; }
}

XfdesktopIconView.view {
  border-radius: 2px;
  background: transparent;
  color: $selected_fg_color;
  text-shadow: $text_shadow;

  &:active, &:checked {
    background-color: $selected_bg_color;
    color: $selected_fg_color;
    text-shadow: none;
  }

  .rubberband { @extend %rubberband; }
}

window#whiskermenu-window {
  background-color: $bg_color;

  // no CSD class even if the sw compositor was enabled.
  > frame > border {
    border-radius: 0;
  }

  scrolledwindow {
    > viewport button.radio {
      padding: 2px 6px;
      margin: 2px;

      &:hover { background-color: if($variant == 'light', rgba(black, 0.12), rgba(white, 0.12)); }

      &:checked, &:active {
        background-color: $selected_bg_color;
        color: $selected_fg_color;

        &:hover { background-image: none; }
      }
    }

    treeview.view {
      &:selected:hover {
        background-color: if($variant == 'light', rgba(black, 0.1), rgba(white, 0.1));
        color: $fg_color;
      }
    }
  }
}

// Thunar
window.background.csd.thunar {
  > grid.horizontal > paned.horizontal > scrolledwindow.frame.sidebar.shortcuts-pane {
    border-bottom-left-radius: $wm_radius;
    background-color: $dark_sidebar_bg;

    treeview.view:not(:hover):not(:selected) {
      background-color: transparent;
    }
  }

  &.maximized, &.tiled, &.fullscreen {
    > grid.horizontal > paned.horizontal > scrolledwindow.frame.sidebar.shortcuts-pane {
      border-bottom-left-radius: $maximized_radius;
    }
  }
}

window.thunar {
  > grid.horizontal > paned.horizontal {
    > scrolledwindow.frame.sidebar.shortcuts-pane {
      border-top: none;
      background-color: $dark_sidebar_bg;

      treeview.view {
        background-color: $dark_sidebar_bg;

        &:hover { background-color: if($variant == 'light', rgba(black, 0.08), rgba(white, 0.08)); }

        &:selected, &:selected:hover, &:active:hover {
          color: $fg_color;
          background-color: $sidebar_theme_color;
        }
      }
    }

    > separator {
      background-image: if($variant == 'light', image($solid_borders_color), image($header_border));
    }
  }

  toolbar#location-toolbar {
    border-bottom: 1px solid $header_border;

    button.path-bar-button,
    button.flat {
      @include button(header-normal);
      margin-left: 0;
      margin-right: 0;
      border-radius: $bt_radius;
      min-height: 28px;

      &:hover { @include button(header-hover); }

      &:checked { @include button(header-checked); }

      &:active { @include button(header-active); }

      &:disabled { @include button(header-insensitive); }

      &:disabled:active, &:disabled:checked { @include button(header-insensitive-active); }
    }

    > toolbutton#open-parent > button.image-button.flat:not(.toggle) {
      margin-left: 10px;
    }

    > toolbutton#open-home > button.image-button.flat:not(.toggle) {
      margin-right: 10px;
    }

    // FIXME: need to unset for weird allocation height
    entry {
      min-height: 22px;
    }
  }

  notebook {
    // hide unneeded border
    stack > scrolledwindow.frame.standard-view {
      border-top-width: 0;
      border-right-width: 0;
    }

    // an allocation height of label node affects to close button's
    // image height (it's quite weird).
    header.top tab.reorderable-page > box > label { min-height: 0; }
  }
}

//
// Geary
//
.geary-main-window.background.csd,
window#GearyMainWindow.background.csd {
  > overlay > box.vertical {
    > paned {
      > separator { @extend %side_separator; }

      > .sidebar {
        border-bottom-left-radius: $wm_radius;

        > searchbar {
          @extend %side_searchbar;
        }

        treeview.view.sidebar {
          padding: 3px 0;

          &:hover {
            color: $fg_color;
            background-color: rgba($fg_color, 0.1);
          }

          &:selected {
            color: $fg_color;
            background-color: rgba($fg_color, 0.15);
          }
        }
      }
    }
  }

  paned.geary-sidebar-pane-separator {
    > separator {
      margin-left: -1px;
      background: none;
    }

    statusbar {
      margin: -8px -12px;
      border: none;
      background-color: rgba($dark_sidebar_bg, 1);
      border-bottom-left-radius: $wm_radius;

      frame > border { border: none; }
    }

    frame.geary-conversation-frame {
      background-color: rgba($dark_sidebar_bg, 1);

      > border { border: none; }

      scrolledwindow {
        background-color: $base_color;
        margin: 6px 6px 6px 0;
        padding: 6px 0;
        border: 1px solid $borders_color;
        border-radius: $bt_radius;

        treeview.view {
          border: none;
          background-image: none;

          &:hover { background-color: rgba($fg_color, 0.1); }

          &:selected {
            background-color: rgba($fg_color, 0.15);
            color: if($variant == 'light', $fg_color, $selected_fg_color);
          }

          &:not(:hover):not(:selected) {
            background: none;
          }
        }
      }
    }
  }

  &.maximized, &.tiled, &.fullscreen {
    > overlay > box.vertical {
      > paned {
        > .sidebar {
          border-bottom-left-radius: $maximized_radius;
        }
      }
    }

    stack#conversation_viewer {
      border-bottom-right-radius: $maximized_radius + 1px;

      scrolledwindow.geary-conversation-scroller {
        viewport.frame {
          border-bottom-right-radius: $maximized_radius;
        }
      }
    }

    paned.geary-sidebar-pane-separator {
      statusbar {
        border-bottom-left-radius: $maximized_radius;
      }
    }
  }
}

.geary-main-window { // 40.0
  > headerbar {
    border-bottom: none;

    > leaflet > leaflet > headerbar {
      border-bottom: none;

      &, &:backdrop {
        border-radius: 0 0 0 0;
      }

      &:only-child {
        border-radius: $wm_radius $wm_radius 0 0;
      }

      &:not(:first-child) {
        background-color: $base_color;
        box-shadow: inset 0 1px $header_highlight;
      }

      &:first-child {
        @extend %side_headerbar_left;
        border-radius: $wm_radius 0 0 0;
      }
    }
  }

  leaflet > leaflet > box.vertical {
    searchbar {
      background-color: $base_color;

      > revealer > box {
        border-color: if($variant == 'light', $solid_borders_color, $header_border);
      }
    }
  }

  frame.geary-folder-frame {
    > border { border: none; }

    scrolledwindow {
      treeview.view.sidebar {
        background-color: rgba($dark_sidebar_bg, 1);

        &:hover {
          color: $fg_color;
          background-color: rgba($fg_color, 0.1);
        }

        &:selected {
          color: $fg_color;
          background-color: rgba($fg_color, 0.15);

          &:hover {
            background-color: rgba($fg_color, 0.12);
          }
        }
      }
    }
  }

  frame.geary-conversation-frame {
    background-color: rgba($dark_sidebar_bg, 1);

    > border { border: none; }

    scrolledwindow {
      background-color: $base_color;

      treeview.view {
        border: none;
        background-image: none;

        &:hover { background-color: rgba($fg_color, 0.1); }

        &:selected {
          background-color: rgba($fg_color, 0.15);
          color: if($variant == 'light', $fg_color, $selected_fg_color);
        }

        &:not(:hover):not(:selected) {
          background: none;
        }
      }
    }
  }

  separator.geary-sidebar-pane-separator { background-color: $dark_sidebar_border; }

  geary-conversation-viewer#conversation_viewer,  // 40.0
  stack#conversation_viewer { // 3.28
    background-color: $base_color;
    border-bottom-right-radius: $wm_radius + 1px;

    scrolledwindow.geary-conversation-scroller {
      viewport.frame {
        background-color: $base_color;
        border-bottom-right-radius: $wm_radius;

        list.conversation-listbox {
          background-color: transparent;
        }
      }
    }

    searchbar {
      background-color: $base_color;

      > revealer > box {
        border-color: if($variant == 'light', $solid_borders_color, $header_border);
      }
    }
  }
}

//
// Dialogs
//
dialog.background.csd {
  background-image: none;
  background-color: $dialog_bg_color;
  border-radius: 0 0 $wm_radius $wm_radius;

  &.maximized { border-radius: 0 0 $maximized_radius $maximized_radius; }

  > headerbar {
    &.titlebar {
      > label:not(.title):not(.subtitle) { // wallpaper set dialog
        font-weight: 700;
      }
    }
  }

  > box.vertical.dialog-vbox {
    &.view { background: none; }

    > grid.horizontal {
      > scrolledwindow.frame { //removed ugly boders for nautilus batch renaming dialog
        border: none;

        > viewport.frame {
          border: none;

          list:first-child { border-radius: 0 0 0 $wm_radius; }
          list:last-child { border-radius: 0 0 $wm_radius 0; }
        }
      }

      > stack {
        > scrolledwindow.frame { // reset border for totem setting dialog
          border: 1px solid $borders_color;
        }
      }
    }

    > stack,
    > stack > stack {
      > scrolledwindow {
        border-radius: 0 0 $wm_radius $wm_radius;
        background-color: $base_color;

        iconview.view:not(:hover):not(:selected):not(:active) { // Wallpaper setting window
          background-color: transparent;
        }
      }
    }

    > stack {
      > scrolledwindow > viewport.frame {
        > list {
          border-radius: 0 0 $wm_radius $wm_radius;

          row.activatable:not(:hover):not(:selected):not(:active) {
            background-color: transparent;
          }
        }
      }

      > box.vertical > stack.view {
        > scrolledwindow > treeview.view:not(:hover):not(:selected):not(:active) {
          background-color: transparent;
        }
      }

      toolbar.toolbar {
        border-radius: 0 0 $wm_radius $wm_radius;
        border-width: 1px 0 0 0;
      }

      > notebook > stack { // Control center wifi setting 3.36 or later
        border-radius: 0 0 $wm_radius $wm_radius;
      }
    }

    > notebook {
      > stack {
        border-radius: 0 0 $wm_radius $wm_radius;

        > box.horizontal > notebook > stack {  // Control center wifi setting
          border-radius: 0 0 $wm_radius $wm_radius;
        }
      }
    }

    separator.vertical { background-color: $borders_color; }

    // Outline for low res icons
    .lowres-icon { // FIXME: not use
      -gtk-icon-shadow: 0 2px 3px rgba(0, 0, 0, 0.15);
    }

    // Dropshadow for large icons
    .icon-dropshadow { // FIXME: not use
      -gtk-icon-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    }

    > .dialog-action-box {
      > .dialog-action-area {
        padding: 3px 6px 6px;
      }
    }
  }

  stack scrolledwindow {
    &.frame {
      border-radius: $wm_radius;

      textview.view {
        border-radius: $wm_radius;

        > text {
          background: none;
        }
      }

      treeview.view:not(:hover):not(:selected) { background: none; }
    }

    viewport.frame {
      &.view { border-radius: $wm_radius; }
    }
  }

  > .dialog-vbox > .dialog-action-box {
    > .dialog-action-area {
      margin: 0 6px 6px;
    }
  }
}


//
// Firefox and Thunderbird
//

window.background:not(.csd) {
  > widget {
    // for the bookmark toolbar's separators
    > separator {
      padding-top: 1px;
      margin-top: 1px;
      min-height: 2px;
      background-color: $borders_color;
    }

    // avoid black border
    > scrollbar {
      background: none;
      border: none;
      // background-clip: border-box;
    }

    // emphasize borders color
    // > scrollbar,
    > frame > border { border-color: $borders_color; }

    > entry,
    .entry { // Set for linked entrys
      // min-height: 26px;
      border-radius: $bt_radius;
      background-image: image($base_color);
      border: 1px solid $borders_color;

      &:focus { border-color: $selection_mode_bg; box-shadow: inset 0 0 0 2px $entry_highlight; }
    }

    > spinbutton {
      background-image: image($button_bg);
      border: 1px solid $borders_color;

      @if $variant == 'light' {
        &:active {
          background-image: image($bg_color);
        }
      }

      // Fixed thunderbird linked entry spinbutton border-radius.
      .entry { border-top-right-radius: 0;  border-bottom-right-radius: 0; }
    }

    > button {
      padding-top: 3px;
      padding-bottom: 3px;
    }

    > button > button {
      outline-style: none;
      border-radius: $bt_radius;

      @if $variant == 'light' {
        &:active {
          border-radius: $bt_radius;
          border: none;
          background-image: image($bg_color);
          box-shadow: inset 0 0 0 1px $borders_color;
        }
      }

      label { padding: 4px 6px; }
    }
  }

  > menu,
  > menu > menu {
    border-radius: 0;
    background-color: $menu_bg;
  }

  > menu > menuitem {
    padding: 4px 6px;

    > label:disabled { color: $disabled_fg_color; }

    > radio,
    > check {
      padding: 0 2px 0 4px;
    }
  }

  > window > menu {
    menuitem {
      transition: none; // Fixed plank menu background issue
    }
  }
}

//
// Firefox Quantum
//

#MozillaGtkWidget {
  // blend with weird toolbar backgrounds
  background-color: $bg_color;

  // FIXME: resetting child elements background is not fully functional yet
  // because WidgetStyleCache keeps holding initial background-color.
  // the stem of this incorrect colouring seems to be caused by their
  // gdk_rgba to ns_rgba conversion. I don't think theme's fault.
  .background,
  frame,
  separator,
  scrolledwindow { background-color: $base_color; }

  scrollbar {
    background: none;
    border: none;

    slider {
      background-color: mix($fg_color, $bg_color, 45%);
      &:hover { background-color: mix($fg_color, $bg_color, 60%); }
      &:hover:active { background-color: mix($fg_color, $bg_color, 75%); }
      &:disabled { background-color: transparent; }
    }
  }

  > window.background > menu { // context-menus
    border: none; // hide ugly double borders
    background-color: $menu_bg;
    border-radius: 2px;

    // revert to standard separators
    > separator {
      margin-top: 2px;
      margin-bottom: 2px;
      background-color: $borders_color;
    }
  }

  > widget {
    // Emphasize toolbar's border-bottom
    > frame > border { border-color: if($variant == 'light', darken($bg_color, 15%), lighten($bg_color, 20%)); }

    // For popover, entry in toolbar, etc.
    text { background-color: $bg_color; }

    // For selection, active tab indicator, etc.
    text:selected {
      // Use traditional selection style as workaround
      background-color: $selected_bg_color;
      color: $selected_fg_color;
    }

    separator { background-color: $borders_color; }

    // FIXME: this affected to popover widget as well,
    // so we can not set $lighter_bg_color to search-bar...
    > scrolledwindow > textview {
      background-color: $menu_bg;

      text {
        background-color: transparent;
        color: if($variant =='light', $text_color, #aaaaaa);

        &:selected,
        &:selected:focus,
        selection { @extend %selected_items; }
      }
    }
  }

  // remove ugly border around the menus
  menu { border: none; }
}

//
// Chrome(ium)
//

$chrome_bg_color: $bg_color;
$chrome_fg_color: $text_color;
$chrome_menu_bg_color: $menu_bg;
$chrome_menu_fg_color: $fg_color;

window.background.chromium {
  // checked-tab & toolbar & button widgets
  background-color: $bg_color;
  color: $text_color;

  headerbar.titlebar {
    button.toggle { // account-button (> 64.0.3282?)
      border: none;
      background-color: transparent;
      background-image: none;

      &:hover { @include button(flat-hover); }
      &:checked, &:active { @include button(flat-active); }
    }

    // from nav_button_provider_gtk3.cc (> 62.0.3202?)
    button.titlebutton { // title-buttons
      // define global titlebutton class sizing
      min-width: 16px;
      min-height: 16px;
      margin: 0; // unset margins
      padding: 0 0;
      background-size: auto;
      color: transparent; // hide stock icons
    }
  }

  // FIXME: not for actual button widgets but for toolbar's separators
  // crazy: src/+/master/chrome/browser/ui/libgtkui/gtk_ui.cc#891
  button { // for active-tab borders
    border-width: 1px;
    border-style: solid;
    border-color: $solid_borders_color;
    background-color: $chrome_bg_color;
    color: $chrome_fg_color;
  }

  entry.chromium {
    &, &:focus { // overrides standard borders
      border-image: none;
      border: 1px solid $solid_borders_color;
      background-color: $chrome_bg_color;
      color: $chrome_fg_color;
    }
  }

  // internal region of toolbar's entry widget
  > textview.view, textview {
    background-color: $chrome_bg_color;
    color: $chrome_fg_color;
  }

  > menubar { background-color: $header_bg; }
}

//
// Libre-Office
//
window.background:not(.solid-csd) {
  // reserved area at the most-right side of GtkMenuBar
  > grid.horizontal > grid.horizontal {
    background-color: $header_bg;
    box-shadow: inset 0 -1px $borders_color;

    > button.flat.small-button {
      // 'close' button
      color: $header_fg;
      border: none;
      border-radius: 50px;
      background-image: none;

      &:hover {
        background-color: lighten($header_bg, 15%);
        color: lighten($header_fg, 5%);
      }

      &:active,
      &:checked {
        background-color: rgba(red, 0.65);
        color: white;
      }

      &:disabled {
        color: rgba($header_fg, 0.6);
      }
    }
  }
}

window.background:not(.solid-csd) {
    // for 'Notebookbar' toolbar
  > notebook:not(.frame) {
    border: 0 none transparent; // unset borders
    background-color: $base_color;

    > stack {
      border: none;
      box-shadow: none;
    }
  }
}

//
// Tilix
//

// in-line titlebars
widget > box.terminal-titlebar {
  padding: 0 6px;

  > button.flat.popup.toggle {
    border: none;
    border-radius: 0;
    padding-top: 0;
    padding-bottom: 0;

    &:dir(ltr) { padding-right: 6px; }
    &:dir(rtl) { padding-left: 6px; }

    &:hover, &:checked, &:active {
      border-radius: 0;
    }

    &:checked, &:active {
      background-color: rgba($fg_color, 0.05);
      color: $fg_color;
    }
  }

  > button.image-button { // 'plus' and 'close'
    &, &.toggle {
      margin: 2px 0;
      padding: 0;
      min-height: 24px;
      min-width: 24px;
      border-radius: $bt_radius;
      // -gtk-outline-radius: $bt_radius;
    }
  }
}

list.tilix-session-sidebar {
  // use -image property instead
  background-image: image($dark_sidebar_bg);
  border-bottom-left-radius: $wm_radius;

  button.tilix-sidebar-close-button {
    min-height: 28px;
    min-width: 28px;
    padding: 0;
    margin: 0;
    border-radius: 100px;
    // -gtk-outline-radius: 100px;
    background-color: $destructive_color;
    &, &:hover, &:active, &:checked { color: white; }

    &:hover { background-color: lighten($destructive_color, 10%); }

    &:active,
    &:checked { background-image: image(darken($destructive_color, 10%)); }
  }
}

$tilix_bg: if($variant == 'light', #ffffff, #151515);

window.background.csd {
  > box.horizontal > stack {
    > box.vertical > notebook > stack {
      border-bottom-right-radius: $wm_radius;
    }
  }

  > overlay > notebook > stack > .tilix-background {
    background-color: $tilix_bg;
    border-radius: 0 0 $wm_radius $wm_radius;

    > .tilix-background {
      background-color: $tilix_bg;
      border-radius: 0 0 $wm_radius $wm_radius;

      .tilix-terminal-scrolledwindow {
        padding-bottom: $wm_radius;
        background-color: $tilix_bg;
        border-radius: 0 0 $wm_radius $wm_radius;

        > vte-terminal {
          border-radius: 0 0 $wm_radius $wm_radius;
        }
      }
    }
  }

  &.maximized, &.tiled, &.fullscreen {
    > box.horizontal > stack {
      > box.vertical > notebook > stack {
        border-bottom-right-radius: $maximized_radius;
      }
    }
  }
}

//
// Lollypop
//
window.background.csd {
  > grid.vertical > overlay > grid.vertical {
    > grid.horizontal {
      > .sidebar {
        border-bottom-left-radius: $wm_radius;
      }

      > paned.horizontal > stack {
        border-bottom-right-radius: $wm_radius;
      }
    }
  }

  &.maximized, &.tiled, &.fullscreen {
    > grid.vertical > overlay > grid.vertical {
      > grid.horizontal {
        > .sidebar {
          border-bottom-left-radius: $maximized_radius;
        }

        > paned.horizontal > stack {
          border-bottom-right-radius: $maximized_radius;
        }
      }
    }
  }
}

//
// Inkscape
//
toolbar#SubToolBox {
  min-height: 36px;

  entry, button {
    margin-top: 6px;
    margin-bottom: 6px;
  }

  > toolbutton > button.flat {
    margin-left: 2px;
    margin-right: 2px;
  }
}

widget#ToolboxCommon {
  button.flat {
    &:active {
      background-color: rgba($fg_color, 0.25);
    }

    &:checked {
      background-color: rgba($fg_color, 0.15);
    }
  }

  // > toolbar > toolitem > button.flat, // Left side
  > toolbar > toolbutton > button.flat { // Right side
    margin-top: 2px;
    margin-bottom: 2px;
  }
}

box#DesktopStatusBar {
  spinbutton, button.combo {
    margin-top: 6px;
    margin-bottom: 6px;
  }
}

//
// Synaptic
//
window > box.vertical > box.horizontal {
  > toolbar {
    background-color: transparent;
    box-shadow: none;

    toolitem > box {
      label,
      entry {
        min-height: 20px;
        padding-top: 2px;
        padding-bottom: 2px;
        font-size: 90%;
      }

      > label { color: $fg_color; }
    }
  }

  > widget { background-color: transparent; }
}

//
// Pamac
//
window.background > box.vertical > overlay > stack > scrolledwindow.frame {
  border: none;

  > viewport.frame > box.vertical > stack > scrolledwindow {
    border-top: 1px solid $borders_color;
  }
}

//
// vala-panel
//
window#ValaPanel.background {
  // background-image: linear-gradient(0deg, $panel_bottom_color 0%, $panel_top_color 100%);
  // border: 1px solid $header_border;
  // color: currentColor;

  widget.-vala-panel-background {
    > separator { // separator applet
      background: none;
    }
  }
}

button.flat.-panel-button,
button#tasklist-button.toggle.flat,
// tasklist-arrow-button.toggle.flat.-panel-flat-button, // xfce tasklist button
button.flat.-panel-icon-button {
  // @extend %budgie_icon_tasklist_button;

  &:hover {
    box-shadow: inset 0 -2px rgba($selected_bg_color, 0.5);
    background: none;
  }

  &:active,
  &:checked {
    box-shadow: inset 0 -2px $selected_bg_color;
    color: if($variant == 'light', darken($panel_fg, 5%), $selected_fg_color);
    background: none;
  }
}

.unpinned button.flat.-panel-icon-button {
  border-radius: 0;

  &:hover,
  &:active,
  &:checked {
    box-shadow: inset 0 -2px $selected_bg_color;
    color: if($variant == 'light', darken($panel_fg, 5%), $selected_fg_color);
  }
}

.pinned button.flat.-panel-icon-button.running {
  border-radius: 0;

  > image {
    background-position: bottom center;
  }

  &:hover,
  &:active,
  &:checked {
    box-shadow: inset 0 -2px $selected_bg_color;
    color: if($variant == 'light', darken($panel_fg, 5%), $selected_fg_color);
  }
}

// vala-panel-appmenu
menubar.-vala-panel-appmenu-private, // xfce4 appmenu plugin
menubar.-vala-panel-background {
  background: none;
  border: none;
  box-shadow: none;

  > menuitem {
    color: $panel_fg;
    font-weight: normal;

    &:hover {
      color: $panel_fg;
      background-color: rgba($panel_fg, 0.2);
    }

    &:disabled {
      color: transparentize($panel_fg, 0.6);
    }

    // > window.background.popup > decoration,
    // > window.background.popup > menu { border-radius: 0 0 $wm_radius $wm_radius; }
  }
}

//
// Elementary Apps
//

// Wingpanel
.menubar.panel {
  .panel {
    &, &.color-light, &.color-dark {
      background-color: transparent;
      background-image: image(rgba($panel_bg, 0.1));
      border-bottom: none;
      transition: all 100ms ease-in-out;
      color: $panel_fg;
    }

    &.maximized {
      background-color: rgba($panel_bg, 0.2);
      background-image: none;
      border: none;
    }

    &.translucent {
      background-color: rgba($panel_bg, 0.1);
      background-image: none;
      border: none;
    }

    menubar {
      background: none;
      box-shadow: none;
      border: none;
    }
  }

  popover {
    padding: 2px 4px;
    margin: 0 6px 15px 6px;
    border: 1px solid if($variant == 'light', rgba(black, 0.35), rgba(black, 0.45));
    box-shadow: 0 3px 5px rgba(black, 0.12), 0 5px 8px rgba(black, 0.08);

    button {
      @include button(undecorated);
      &:hover { @include button(flat-hover); }
      &:active { @include button(flat-active); label { color: white; } }
      &:checked { @include button(flat-checked); label { color: white; } }
      &:disabled { @include button(flat-insensitive); }
      &, &:hover, &:active, &:checked, &:disabled { border-color: transparent; }
    }

    .linked > button {
      @include button(normal);
      &:hover { @include button(hover); }
      &:active, &:checked { @include button(active); }
      &:disabled { @include button(insensitive); }
    }

    list { background-color: transparent; }

    separator.horizontal {
      margin: 0 -4px;
    }

    separator.vertical {
      background: none;
    }

    .sidebar {
      border-style: none;
      background: none;

      .view {
        background: none;

        &:hover {
          border-radius: $bt_radius;
          background-color: if($variant=='light', rgba(black, 0.1), rgba(white, 0.1));
        }

        &:selected {
          &, &:focus, &:backdrop {
            text-shadow: none;
            transition: all 200ms $ease-out-quad;
            background-color: if($variant=='light', rgba(black, 0.65), rgba(white, 0.35));
            border-radius: $bt_radius;
          }
        }
      }
    }
  }
}

.composited-indicator {
  padding: 0 6px;

  > revealer label,
  > revealer image,
  > revealer spinner {
    color: $panel_fg;
    font-weight: normal;
    transition: all 200ms ease-in-out;
    text-shadow: none;
    -gtk-icon-shadow: none;
  }

  > revealer image,
  > revealer spinner {
    padding: 3px 0;
  }

  > revealer label {
    padding: 3px 6px;
  }

  .keyboard {
    background-color: $panel_fg;
    border-radius: 2px;
    color: $panel_bg;
    padding: 0 3px;
    font-weight: normal;
    box-shadow: none;
    text-shadow: none;
  }
}

// Popover switcher dots
button.flat.toggle.switcher {
  &:hover, &:active, &:checked, &:selected {
    image {
      color: $selected_bg_color;
    }
  }
}

// Calendar Popover
.circular { // Calendar popover date button
  label:disabled { color: $disabled_fg_color; }

  &.accent { // Today button
    color: $selected_fg_color;
    background-color: $selected_bg_color;
  }
}

// Marlin / Pantheon Files
MarlinViewWindow {
  *:selected, *:selected:focus {
    color: $selected_fg_color;
    background-color: $selected_bg_color;
    outline-color: transparent;
  }

  GtkIconView.view:selected {
    &, &:focus, &:hover, &:focus:hover { background-color: transparent; }
  }

  FMListView, FMColumnView { outline-color: transparent; }
}

.marlin-pathbar.pathbar {
  padding-left: 4px;
  padding-right: 4px;

  @include entry(header-normal);
  &:focus { @include entry(header-focus) }
  &:disabled { @include entry(header-insensitive) }
}

window.background.csd {
  > paned.horizontal {
    > separator {
      &:dir(ltr) { margin-left: -1px; }
      &:dir(rtl) { margin-right: -1px; }
    }

    > scrolledwindow {
      > viewport.frame {
        > box.vertical treeview.view {

          border-right: 1px solid if($variant=='light', $solid_borders_color, $header_border);

          &:not(:hover):not(:selected) {
            border-bottom-left-radius: $wm_radius;
            background: none;
          }

          color: $dark_sidebar_fg;
          padding-top: 3px;
          padding-bottom: 3px;
          border-right: 1px solid $header_border;
          // @extend %view;

          &:not(:selected):hover { background-color: if($variant == 'light', rgba(black, 0.05), rgba(white, 0.05)); }

          &:selected, &:selected:hover, &:selected:focus {
            color: $fg_color;
            background-color: $sidebar_theme_color;
            &, label { color: $fg_color; }
          }

          image {
            color: $dark_sidebar_fg;
            &:selected { color: $selected_fg_color; }
            &:disabled { color: rgba($dark_sidebar_fg, 0.45); }
          }

          &.trough {
            color: $fg_color;
            background-color: $button_border;
            border-radius: $bt_radius;
            border-width: 0;

            &:selected, &:selected:focus {
              color: $selected_fg_color;
              background-color: transparentize(black, 0.8);
              border-radius: $bt_radius;
              border-width: 0;
            }
          }
        }
      }
    }
  }

  > stack > stack {
    > paned.horizontal {
      > scrolledwindow > viewport.frame {
        list {
          border-bottom-left-radius: $wm_radius;
        }
      }
    }
  }

  &.maximized, &.tiled, &.fullscreen {
    > stack > stack {
      > paned.horizontal {
        > scrolledwindow > viewport.frame {
          list {
            border-bottom-left-radius: $maximized_radius;
          }
        }
      }
    }
  }
}

.dynamic-notebook {
  > notebook {
    > stack {
      border-bottom-right-radius: $wm_radius;
      background-color: $base_color;

      scrolledwindow.view.h2 {
        background-color: transparent;
      }

      treeview.view,
      iconview.view {
        &:not(:hover):not(:selected) { background: none; }
        &:hover { background-color: if($variant == 'light', rgba(black, 0.05), rgba(white, 0.05)); }
        &:selected {
          color: $fg_color;
          background-color: if($variant == 'light', rgba(black, 0.1), rgba(white, 0.1));
        }
      }
    }

    treeview.view {
      > frame.cell {
        > entry {
          border-image-width: 0;
          background-color: $bg_color;

          &:focus { background-color: $base_color; }
        }

        > border { border: none; }
      }
    }
  }
}

headerbar.titlebar {
  > box.horizontal > entry.pathbar {
    min-height: 20px;
    padding: 2px 6px;
    margin-top: 0;
    margin-bottom: 0;
  }

  > button.flat.image-button.toggle:dir(ltr) {
    min-height: 0;
    margin-top: 8px;
    margin-bottom: 8px;

    &:not(:checked):not(:active) {
      background-clip: if($variant=='light', padding-box, padding-box);
    }

    @if $variant == 'light' {
      border-width: 1px;
      border-style: solid;
      border-color: $borders_color;
    }

    @include button(header-normal);
    &:hover { @include button(header-hover); }
    &:active { @include button(header-active); }
    &:checked { @include button(header-checked); }
    &:disabled { color: transparentize($header_fg, 0.4); }
    &:backdrop { opacity: 0.7; background-image: none;}

    + button.flat.image-button.toggle { margin-right: if($variant=='light', -6px, -5px); }
  }

  > .linked.raised > button.toggle {
    margin-top: 4px;
    margin-bottom: 4px;
  }

  // Hide Code header format-bar
  > grid.linked.horizontal.format-bar {
    margin-top: 6px;
    margin-bottom: 6px;
    border: none;

    button.toggle {
      margin-top: 0;
      margin-bottom: 0;
    }

    &:backdrop {
      transition: $backdrop_transition;
      background-image: none;
      background-color: $header_bg_backdrop;
    }
  }
}

// Gala
.gala-notification {
    border: 1px solid $dark_borders_color;
    border-radius: $wm_radius;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    background-image: _solid($osd_bg_color);
    background-color: transparent;

  .title, .label {
    color: $osd_fg_color;
  }
}

// system setting
actionbar.inline-toolbar {
  border: none;
  border-top: 1px solid $borders_color;

  button { // Reset buttons
    border-radius: $bt_radius;
    // border: 1px solid $dark_borders_color;

    &:first-child {
      border-right-style: solid;
    }

    &:last-child {
      border-left-style: solid;
    }
  }
}

// Nightlight warmth trough
scale.warmth trough {
  min-height: 4px;
  border-radius: 3px;
  background-image: linear-gradient(to right, $suggested_color, $destructive_color);
  box-shadow: inset 0 0 0 1px rgba(black, 0.25);
}

// Terminal
.terminal-window {
  headerbar.titlebar.default-decoration {
    background-color: $header_bg;
    border-bottom: 1px solid $header_border;
    box-shadow: inset 0 1px $highlight_color;

    &:backdrop {
      transition: $backdrop_transition;
      color: transparentize($header_fg, 0.3);
      background-image: none;
      background-color: $header_bg_backdrop;
      border-color: if($variant=='light', lighten($header_border, 15%), darken($header_border, 3%));
    }
  }

  .search-bar {
    background-color: $bg_color;
    border-bottom: 1px solid $solid_borders_color;
  }

  .dynamic-notebook {
    notebook > header { border-color: $solid_borders_color; }
  }
}