@layer sketches {
  .lt-head:not(.lt-head--pills, .lt-head--track, .lt-head--bar, .lt-head--bar_outline) .page-head__inner {
    padding-bottom: 0;
  }

  .lt-tabs {
    position: relative;
    top: 1px;
    display: flex;
    align-items: flex-end;
    gap: var(--space-xl);
    margin-top: var(--space-lg);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .lt-tab {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) 0 0.75rem;
    font-weight: var(--weight-emphasis);
    white-space: nowrap;
    color: var(--ink-muted);
    border-bottom: 3px solid transparent;

    & .icon {
      flex: none;
      width: 1.1rem;
      height: 1.1rem;
    }

    & .icon:not(.icon--salesforce) {
      color: var(--ink-faint);
    }

    &:hover {
      color: var(--ink);
    }

    &[aria-current="page"] {
      color: var(--navy);
      border-bottom-color: var(--navy);

      & .icon:not(.icon--salesforce),
      & :is(.lt-tab__count, .lt-tab__figure) {
        color: var(--navy);
      }
    }
  }

  /* List title sketch: a label strip above each full-width option. */
  .list-title-label {
    padding-block: var(--space-sm);
    font-size: var(--text-sm);
    font-weight: var(--weight-display);
    color: var(--paper);
    background: var(--periwinkle);

    .page + & {
      margin-top: var(--space-2xl);
    }

    & .page {
      display: block;
    }
  }

  .list-title-spacer {
    height: var(--space-2xl);
  }

  /* ?width= tries other page widths on any sketch; the list and the project page share it. */
  :root[data-sketch-width="1280"] .page {
    --page-width: 1280px;
  }

  :root[data-sketch-width="1360"] .page {
    --page-width: 1360px;
  }

  :root[data-sketch-width="1440"] .page {
    --page-width: 1440px;
  }

  .lt-tab__count {
    font-size: var(--text-sm);
    font-weight: var(--weight-display);
    font-variant-numeric: tabular-nums;
    color: var(--ink-muted);
  }

  /* B. Folder tabs: the current tab is a white card that opens onto the list. */
  .lt-head--folder {
    & .lt-tabs {
      gap: var(--space-xs);
    }

    & .lt-tab {
      padding: 0.75rem var(--space-lg);
      border: 1px solid transparent;
      border-bottom: 0;
      border-radius: var(--radius-md) var(--radius-md) 0 0;

      &:hover {
        background: var(--hairline);
      }

      &[aria-current="page"] {
        background: var(--paper);
        border-color: var(--border);
      }
    }
  }

  /* H. Tab bar, after Safari: one rounded bar across the full width, split evenly between the
     mailboxes. The current one is a white tab raised inside it; thin rules part the others. */
  .lt-head--bar,
  .lt-head--bar_outline {
    & .lt-tabs {
      top: 0;
      display: grid;
      grid-auto-columns: minmax(0, 1fr);
      grid-auto-flow: column;
      align-items: stretch;
      gap: 0;
      padding: 3px;
      border-radius: 11px;
    }

    & .lt-tab {
      position: relative;
      justify-content: center;
      padding: 0.5rem var(--space-md);
      border-bottom: 0;
      border-radius: var(--radius-md);

      &[aria-current="page"] {
        background: var(--paper);
        box-shadow: var(--button-shadow), 0 0 0 1px rgb(0 33 51 / 0.06);
      }

      &:not([aria-current="page"]) + &:not([aria-current="page"])::before {
        content: "";
        position: absolute;
        inset: 0.625rem auto 0.625rem -0.5px;
        width: 1px;
        background: var(--border);
      }
    }
  }

  .lt-head--bar {
    & .lt-tabs {
      background: var(--hairline);
    }

    & .lt-tab:hover:not([aria-current="page"]) {
      background: color-mix(in oklab, var(--hairline), var(--border) 45%);
    }
  }

  .lt-head--bar_outline {
    & .lt-tabs {
      border: 1px solid var(--border);
    }

    & .lt-tab:hover:not([aria-current="page"]) {
      background: var(--hairline);
    }
  }

  /* F. Flush tabs: no outline; the current tab is the page's white rising into the header, with curved feet. */
  .lt-head--flush,
  .lt-head--flush_outline {
    & .lt-tabs {
      gap: var(--space-xs);
      overflow: visible;
    }

    & .lt-tab {
      position: relative;
      padding: 0.75rem var(--space-lg);
      border-bottom: 0;
      border-radius: 12px 12px 0 0;

      &:hover:not([aria-current]) {
        background: none;

        &::before {
          content: "";
          position: absolute;
          inset: 0.375rem 0 0.5rem;
          z-index: -1;
          background: var(--hairline);
          border-radius: var(--radius-md);
        }
      }

      &[aria-current="page"] {
        background: var(--paper);

        &::before,
        &::after {
          content: "";
          position: absolute;
          bottom: 0;
          width: 12px;
          height: 12px;
        }

        &::before {
          left: -12px;
          background: radial-gradient(circle at 0 0, transparent 12px, var(--paper) 12.5px);
        }

        &::after {
          right: -12px;
          background: radial-gradient(circle at 100% 0, transparent 12px, var(--paper) 12.5px);
        }
      }
    }
  }

  .lt-head--flush .lt-tabs,
  .lt-head--flush_outline .lt-tabs {
    isolation: isolate;
  }

  /* Flush: the header has no bottom rule, so only the grey band meets the white page and the tab. */
  .lt-head--flush {
    border-bottom-color: transparent;
  }

  /* Flush, outlined: the header's rule runs up the feet, around the tab and back down. */
  .lt-head--flush_outline .lt-tab[aria-current="page"] {
    border: 1px solid var(--border);
    border-bottom: 0;

    &::before,
    &::after {
      bottom: 0;
      width: 13px;
      height: 13px;
    }

    &::before {
      left: -13px;
      background: radial-gradient(circle at 0 0, transparent 11.5px, var(--border) 12px, var(--border) 12.5px, var(--paper) 13px);
    }

    &::after {
      right: -13px;
      background: radial-gradient(circle at 100% 0, transparent 11.5px, var(--border) 12px, var(--border) 12.5px, var(--paper) 13px);
    }
  }

  /* G. Line tabs: a 2px navy line on the header's edge, counts in small badges. */
  .lt-head--line {
    & .lt-tabs {
      gap: var(--space-xs);
    }

    & .lt-tab {
      position: relative;
      padding: 0.5rem 0.75rem 0.875rem;
      border-bottom: 0;

      &::after {
        content: "";
        position: absolute;
        inset: auto 0 0;
        height: 2px;
        border-radius: 2px 2px 0 0;
      }

      &:hover:not([aria-current]) {
        background: none;

        &::before {
          content: "";
          position: absolute;
          inset: 0 0 0.375rem;
          z-index: -1;
          background: var(--hairline);
          border-radius: var(--radius-md);
        }
      }

      &[aria-current="page"]::after {
        background: var(--navy);
      }
    }

    & .lt-tab__count {
      min-width: 1.5rem;
      padding: 0.0625rem 0.4375rem;
      text-align: center;
      background: var(--hairline);
      border-radius: var(--radius-pill);
    }

    & .lt-tab[aria-current="page"] .lt-tab__count {
      color: var(--paper);
      background: var(--navy);
    }
  }

  .lt-head--line .lt-tabs {
    isolation: isolate;
  }

  /* D. Pills: slightly rounded, lifted off the header's bottom edge. Same hover and current colours as the folder tabs. */
  .lt-head--pills,
  .lt-head--track {
    & .lt-tabs {
      top: 0;
      align-items: center;
      gap: var(--space-xs);
    }

    & .lt-tab {
      padding: 0.5rem 0.875rem;
      border: 1px solid transparent;
      border-radius: var(--radius-md);

      &:hover {
        background: var(--hairline);
      }

      &[aria-current="page"] {
        background: var(--paper);
        border-color: var(--border);
        box-shadow: var(--button-shadow);
      }
    }
  }

  /* E. Pills in a track: the same pills held in one outlined strip, like a segmented control. */
  .lt-head--track .lt-tabs {
    width: fit-content;
    max-width: 100%;
    padding: 3px;
    gap: 2px;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius-md) + 4px);
  }

  /* C. Count tabs: the count is the figure, the name sits under it. */
  .lt-head--counts {
    & .lt-tabs {
      gap: var(--space-2xl);
    }

    & .lt-tab {
      flex-direction: column;
      align-items: flex-start;
      gap: var(--space-xs);
    }
  }

  .lt-tab__figure {
    font-size: var(--text-figure);
    font-weight: var(--weight-display);
    font-variant-numeric: tabular-nums;
    line-height: 1;
    letter-spacing: var(--tracking-display);
    color: var(--ink-muted);
  }

  .lt-tab__label {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
  }

  @media (max-width: 720px) {
    .lt-tabs {
      gap: var(--space-lg);
      margin-inline: calc(-1 * var(--space-md));
      padding-inline: var(--space-md);
    }

    .lt-head--counts .lt-tabs {
      gap: var(--space-xl);
    }

    /* The bar gives way to the mailbox menu, as the live tabs do. */
    :is(.lt-head--bar, .lt-head--bar_outline) .lt-tabs {
      display: none;
    }
  }
}
