.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0 8px var(--edge);
  overflow: hidden auto;  /* a short laptop screen scrolls the list, as a Mac sidebar does, with no bar showing */
  scrollbar-width: none;
  white-space: nowrap;
  background: var(--color-sidebar);
  border-right: .5px solid var(--color-separator);
  transition: opacity .2s ease;
}

:root[data-theme="dark"] .sidebar {
  border-right-color: rgba(0, 0, 0, .6);
}

:root[data-sidebar="hidden"] .sidebar {
  opacity: 0;
  pointer-events: none;
  border-right-color: transparent;
}

.sidebar-brand {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  height: var(--bar-height);
  padding: 0 8px;
  font: 700 15px var(--font-display);  /* the name in bold, as heavy as its mark beside it */
  letter-spacing: -.01em;
}

/* the mark and "Pie" open pie-project.org, and read as the name they are, not as a link; the whole row is the link,
   edge to edge and the bar's full height, so a click anywhere across the brand opens it */
.sidebar-home { display: flex; flex: 1; align-self: stretch; align-items: center; gap: 8px; margin: 0 -8px; padding: 0 8px; color: var(--color-label); text-decoration: none; }


.sidebar-logo {
  width: 16px;
  height: 16px;
  transform-box: fill-box;
  transform-origin: center;
}

.sidebar-logo.is-spinning {
  animation: logo-spin .9s cubic-bezier(.65, 0, .35, 1);
}

@keyframes logo-spin {
  0% {
    transform: rotate(0) scale(1);
  }
  45% {
    transform: rotate(200deg) scale(.82);
  }
  100% {
    transform: rotate(360deg) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar-logo.is-spinning {
    animation: none;
  }
}

.sidebar-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin: 0 -4px 0 auto;
  border-radius: var(--radius-control);
  color: var(--color-label-secondary);
}

.sidebar-help:hover {
  background: var(--color-hover);
  color: var(--color-label);
}

.sidebar-help svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
}

.sidebar-heading {
  padding: 16px 8px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-label-tertiary);
}

.sidebar-heading:first-child {
  padding-top: 4px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: var(--control-height);
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-control);
  background: none;
  color: var(--color-label);
  text-align: left;
}

/* no fill under the pointer: a macOS sidebar fills only the selection, so the row you are on is never in doubt */

.sidebar-item.is-selected {
  background: var(--color-selection);
}

.sidebar-item svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-count {
  margin-left: auto;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--color-label-secondary);
}

/* outlined like the Beta tags in System Settings */
/* drawn as the site's other tags (a card's Fastest): grey fill, no border */
.sidebar-tag {
  margin-left: auto;
  padding: 0 5px;
  border-radius: 4px;
  color: var(--color-label-secondary);
  background: var(--color-fill);
  font-size: 10px;
  font-weight: 500;
  line-height: 15px;
}

.sidebar-backdrop,
.sidebar-settings,
.sidebar-appearance {
  display: none;
}

/* below the desktop width the sidebar slides over the page from the left, the page dimmed behind it, as in iPadOS */
@media (max-width: 899px) {
  .sidebar,
  :root[data-sidebar="hidden"] .sidebar {
    position: fixed;
    z-index: 40;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(320px, 85vw);
    padding: env(safe-area-inset-top) 10px max(var(--edge), env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    overflow-y: auto;
    overscroll-behavior: contain;
    opacity: 1;
    border-right: 0;
    visibility: hidden;
    pointer-events: auto;
    transform: translateX(-100%);
    transition: transform .35s cubic-bezier(.32, .72, 0, 1), visibility 0s .35s;
  }

  :root[data-drawer="open"] .sidebar {
    visibility: visible;
    transform: none;
    box-shadow: 0 0 40px rgba(0, 0, 0, .22);
    transition: transform .35s cubic-bezier(.32, .72, 0, 1);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    z-index: 39;
    inset: 0;
    background: rgba(0, 0, 0, .32);
    opacity: 0;
    pointer-events: none;
    transition: opacity .35s ease;
  }

  :root[data-drawer="open"] .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-brand {
    height: 56px;
    padding: 0 10px;
    font-size: 20px;
    font-weight: 400;
  }

  .sidebar-logo {
    width: 20px;
    height: 20px;
  }

  .sidebar-help {
    width: 44px;
    height: 44px;
    margin-right: -10px;
  }

  .sidebar-help svg {
    width: 20px;
    height: 20px;
  }

  .sidebar-heading {
    padding: 20px 10px 6px;
    font-size: 13px;
  }

  .sidebar-item {
    gap: 12px;
    height: 44px;
    padding: 0 10px;
    border-radius: 10px;
    font-size: 17px;
  }

  .sidebar-item svg {
    width: 20px;
    height: 20px;
  }

  .sidebar-glyph[style] {
    width: 28px;
    height: 28px;
    margin-left: -4px;
    border-radius: 7px;
    box-shadow: inset 0 0 0 .5px rgba(255, 255, 255, .18);
  }

  .sidebar-glyph[style] svg {
    width: 17px;
    height: 17px;
  }

  .sidebar-count {
    font-size: 15px;
  }

  .sidebar-item.is-selected {
    background: var(--color-accent);
    color: var(--color-on-accent);
  }

  .sidebar-item.is-selected svg {
    stroke: currentColor;
  }

  /* the appearance switch at the foot of the slide-over, under a Settings heading as every other group has one */
  .sidebar-settings { display: block; }  /* the same gap above it as above every group */
  .sidebar-appearance {
    display: flex;
    flex: none;
    padding-top: 0;
    border-radius: 0;
    height: 44px;  /* a row like the others */
  }

  .sidebar-nav {
    padding-bottom: 0;  /* Settings follows with its heading's own gap */
  }




  .sidebar-item.is-selected .sidebar-glyph[style] {
    box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .85);
  }

  .sidebar-item.is-selected .sidebar-count {
    color: rgba(255, 255, 255, .8);
  }

  .sidebar-item.is-selected .sidebar-tag {
    border-color: rgba(255, 255, 255, .6);
    color: var(--color-on-accent);
  }
}

@media (max-width: 899px) and (prefers-reduced-motion: reduce) {
  .sidebar,
  .sidebar-backdrop {
    transition: none !important;
  }
}


/* a platform's icon: a small tinted squircle with a white glyph, like the model badges and Apple's settings */
.sidebar-glyph { display: inline-flex; }
.sidebar-glyph[style] {
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: -2px;
  border-radius: 5px;
  background: var(--tint);
}
.sidebar-glyph[style] svg { width: 13px; height: 13px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }  /* the platform's mark drawn in white on its tile, wherever the tile sits (a menu too) */
.sidebar-glyph[style] svg .is-filled { fill: #fff; stroke: none; }  /* Apple's mark is a filled glyph */
.sidebar-item .sidebar-glyph[style] svg .is-filled { fill: #fff; stroke: none; }
.sidebar-item svg .is-filled { fill: var(--color-label); stroke: none; }


/* a sidebar row that opens another site: an arrow at its end, as a Mac sidebar marks a link out of the app */
.sidebar-item.is-link { text-decoration: none; color: inherit; }
.sidebar-item .sidebar-out { width: 12px; height: 12px; margin-left: auto; fill: none; stroke: var(--color-label-tertiary); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.sidebar::-webkit-scrollbar { display: none; }

/* the production look: plain line symbols in grey with no coloured tiles, the page's own background behind the list, a
   soft fill under the pointer and a firmer one, with the symbol in full ink, on the page that is open */
.sidebar { background: var(--color-background); }
.sidebar .sidebar-glyph[style] { width: 16px; height: 16px; margin-left: 0; border-radius: 0; background: none; box-shadow: none; }
.sidebar-item svg, .sidebar .sidebar-glyph[style] svg { width: 16px; height: 16px; stroke: var(--color-label-secondary); stroke-width: 1.3; }
.sidebar-item svg .is-filled, .sidebar-item .sidebar-glyph[style] svg .is-filled { fill: var(--color-label-secondary); stroke: none; }
.sidebar-item:hover { background: var(--color-hover); }
.sidebar-item.is-selected { background: var(--color-fill); }
.sidebar-item.is-selected svg, .sidebar-item.is-selected .sidebar-glyph[style] svg { stroke: var(--color-label); }
.sidebar-item.is-selected svg .is-filled { fill: var(--color-label); }
/* a platform keeps its coloured tile, as the tables show it: the white mark on its tint */
.sidebar .sidebar-item.is-platform .sidebar-glyph[style] { width: 16px; height: 16px; margin: 0; border-radius: 4px; background: var(--tint); }  /* the tile in the 16px slot every icon has, as the hardware rows draw it */
.sidebar .sidebar-item.is-platform .sidebar-glyph[style] svg { width: 11px; height: 11px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sidebar .sidebar-item.is-platform .sidebar-glyph[style] svg .is-filled { fill: #fff; stroke: none; }
.sidebar-item .sidebar-out { stroke: var(--color-label-tertiary); }
/* a row that leaves the site: on hover its arrow darkens and nudges toward where it goes; no ring after a click */
.sidebar-item:focus:not(:focus-visible) { outline: none; }
.sidebar-item.is-link .sidebar-out { transition: transform .15s ease, stroke .15s ease; }
.sidebar-item.is-link:hover .sidebar-out { stroke: var(--color-label-secondary); transform: translate(1.5px, -1.5px); }
.sidebar-item.is-link .sidebar-glyph[style] svg .is-filled { fill: var(--tint); }
/* the name and its mark as a black capsule, the Log in button's height, colours and corner (inverted in dark mode) */
.sidebar .sidebar-home { flex: none; align-self: center; gap: 8px; height: 28px; margin: 0; padding: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; color: var(--color-label); background: none; }  /* the mark and the name in the label colour, no plate, as a site's wordmark sits */
.sidebar .sidebar-home:hover { opacity: 1; }  /* no fade on hover either */
.sidebar .sidebar-home .sidebar-logo { width: 16px; height: 16px; transform: translateY(1px); }  /* the mark a point lower, level with the name's letters */
.sidebar .sidebar-logo.is-spinning { animation: none; }  /* the brand button keeps still */
/* phones, in the same production look: the open page in a soft grey with its name in full ink, no ring round its symbol */
@media (max-width: 899px) {
  .sidebar .sidebar-item.is-selected { color: var(--color-label); background: var(--color-fill); }
  .sidebar .sidebar-item.is-selected svg { stroke: var(--color-label); }
  .sidebar .sidebar-glyph[style], .sidebar .sidebar-item.is-selected .sidebar-glyph[style] { width: 20px; height: 20px; margin-left: 0; box-shadow: none; background: none; }
  .sidebar .sidebar-item.is-selected .sidebar-count { color: var(--color-label-secondary); }
  .sidebar .sidebar-item.is-selected .sidebar-tag { color: var(--color-label-secondary); }
}
@media (max-width: 899px) {
  .sidebar .sidebar-home { height: 44px; gap: 8px; font-size: 17px; }  /* the drawer's rows' height and type */
  .sidebar .sidebar-home .sidebar-logo { width: 16px; height: 16px; }
}
@media (max-width: 899px) { .sidebar .sidebar-home { border-radius: 999px; } }  /* a capsule, as Log in on the bar */
.sidebar .sidebar-heading { font-weight: 400; }  /* a section's name in the plain weight, its grey enough to set it apart */
