.app-shell {
  grid-template-columns: max-content minmax(310px, 410px) minmax(0, 1fr);
}

.side-rail {
  width: max-content;
}

.nav-tabs {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.mobile-nav-placeholder {
  display: none;
}

.nav-tab {
  align-items: center;
  display: flex;
  font-size: 12px;
  font-weight: 700;
  justify-content: flex-start;
  line-height: 1.15;
  padding: 0 14px;
  text-align: left;
  width: auto;
}

.nav-tab.active {
  background: color-mix(in srgb, var(--blue) 15%, var(--panel));
}

@media (min-width: 901px) {
  body {
    min-height: 100svh;
  }

  @media (hover: hover) and (prefers-reduced-motion: no-preference) {
    .nav-tab,
    .side-rail .theme-toggle {
      transition: color 160ms ease, transform 160ms ease;
    }

    .nav-tab:hover,
    .side-rail .theme-toggle:hover {
      color: var(--blue);
      transform: scale(1.05);
    }
  }

  .app-shell {
    left: 50%;
    margin: 0;
    position: fixed;
    top: 50%;
    transform: translate(-50%, -50%);
  }

}

@media (min-width: 901px) and (max-height: 667px) {
  .app-shell {
    left: auto;
    margin: 24px auto;
    position: relative;
    top: auto;
    transform: none;
  }
}

@media (max-width: 900px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    max-width: 720px;
    min-width: 0;
    width: calc(100vw - 2rem);
  }

  .side-rail {
    background: transparent;
    border-radius: 0;
    display: grid;
    flex: none;
    gap: 7px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    max-width: 100%;
    overflow: visible;
    padding: 0;
    width: 100%;
  }

  .side-rail .nav-tabs {
    display: grid;
    gap: 7px;
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .mobile-nav-placeholder { order: 0; }

  .mobile-nav-placeholder.is-active {
    display: block;
  }

  .side-rail.is-mobile-floating {
    background: transparent;
    border-radius: 0;
    left: var(--mobile-nav-left);
    max-width: 720px;
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    transform: none;
    width: var(--mobile-nav-width);
    z-index: 30;
  }

  .side-rail .nav-tab {
    background: var(--panel);
    border: 2px solid var(--blue);
    border-radius: 12px;
    justify-content: center;
    min-width: 0;
    padding: 0 6px;
    text-align: center;
    white-space: nowrap;
    width: 100%;
  }

  .side-rail .nav-tab.active {
    background: color-mix(in srgb, var(--blue) 15%, var(--panel));
  }

  .profile-card,
  .content-panel,
  .tab-panel {
    max-width: 100%;
    min-width: 0;
    width: 100%;
  }

  .profile-card {
    display: none;
  }

  body.is-about-tab .profile-card {
    display: flex;
  }

  body.is-about-tab .profile-media {
    height: 300px;
    min-height: 300px;
  }

  .content-panel {
    overflow-x: hidden;
  }

  .profile-media,
  .profile-photo {
    max-width: 100%;
    min-width: 0;
  }

  .content-panel h1,
  .content-panel h2,
  .content-panel h3,
  .content-panel h4,
  .content-panel p,
  .content-panel b,
  .content-panel span {
    overflow-wrap: anywhere;
  }

  .site-signature {
    margin: 0 auto 1rem;
    position: static !important;
    text-align: center;
    transform: none !important;
  }
}

@media (prefers-reduced-motion: no-preference) {
  @media (max-width: 900px) {
    .side-rail.is-mobile-floating .nav-tab {
      animation: mobile-nav-enter 160ms ease-out;
    }
  }
}

@keyframes mobile-nav-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}

.site-signature {
  bottom: auto;
  color: var(--muted);
  display: block;
  font-family: Caveat, cursive;
  font-size: clamp(.75rem, 1vw, 1rem);
  font-weight: 600;
  left: 50%;
  letter-spacing: .02em;
  line-height: 1;
  opacity: .6;
  pointer-events: none;
  position: fixed;
  text-transform: uppercase;
  top: var(--signature-top, 50%);
  transform: translate(-50%, -50%);
  z-index: 2;
}
